1
+ use std:: fmt:: Debug ;
1
2
use std:: marker:: PhantomData ;
2
3
3
4
use crate :: traits:: error_reporting:: { OverflowCause , TypeErrCtxtExt } ;
@@ -6,7 +7,7 @@ use crate::traits::{BoundVarReplacer, PlaceholderReplacer, ScrubbedTraitError};
6
7
use rustc_data_structures:: stack:: ensure_sufficient_stack;
7
8
use rustc_infer:: infer:: at:: At ;
8
9
use rustc_infer:: infer:: InferCtxt ;
9
- use rustc_infer:: traits:: { FromSolverError , FulfillmentErrorLike , Obligation , TraitEngine } ;
10
+ use rustc_infer:: traits:: { FromSolverError , Obligation , TraitEngine } ;
10
11
use rustc_middle:: traits:: ObligationCause ;
11
12
use rustc_middle:: ty:: { self , Ty , TyCtxt , UniverseIndex } ;
12
13
use rustc_middle:: ty:: { FallibleTypeFolder , TypeFolder , TypeSuperFoldable } ;
@@ -16,14 +17,11 @@ use super::{FulfillmentCtxt, NextSolverError};
16
17
17
18
/// Deeply normalize all aliases in `value`. This does not handle inference and expects
18
19
/// its input to be already fully resolved.
19
- pub fn deeply_normalize <
20
- ' tcx ,
20
+ pub fn deeply_normalize < ' tcx , T , E > ( at : At < ' _ , ' tcx > , value : T ) -> Result < T , Vec < E > >
21
+ where
21
22
T : TypeFoldable < TyCtxt < ' tcx > > ,
22
23
E : FromSolverError < ' tcx , NextSolverError < ' tcx > > ,
23
- > (
24
- at : At < ' _ , ' tcx > ,
25
- value : T ,
26
- ) -> Result < T , Vec < E > > {
24
+ {
27
25
assert ! ( !value. has_escaping_bound_vars( ) ) ;
28
26
deeply_normalize_with_skipped_universes ( at, value, vec ! [ ] )
29
27
}
@@ -34,31 +32,34 @@ pub fn deeply_normalize<
34
32
/// Additionally takes a list of universes which represents the binders which have been
35
33
/// entered before passing `value` to the function. This is currently needed for
36
34
/// `normalize_erasing_regions`, which skips binders as it walks through a type.
37
- pub fn deeply_normalize_with_skipped_universes <
38
- ' tcx ,
39
- T : TypeFoldable < TyCtxt < ' tcx > > ,
40
- E : FromSolverError < ' tcx , NextSolverError < ' tcx > > ,
41
- > (
35
+ pub fn deeply_normalize_with_skipped_universes < ' tcx , T , E > (
42
36
at : At < ' _ , ' tcx > ,
43
37
value : T ,
44
38
universes : Vec < Option < UniverseIndex > > ,
45
- ) -> Result < T , Vec < E > > {
39
+ ) -> Result < T , Vec < E > >
40
+ where
41
+ T : TypeFoldable < TyCtxt < ' tcx > > ,
42
+ E : FromSolverError < ' tcx , NextSolverError < ' tcx > > ,
43
+ {
46
44
let fulfill_cx = FulfillmentCtxt :: new ( at. infcx ) ;
47
45
let mut folder =
48
46
NormalizationFolder { at, fulfill_cx, depth : 0 , universes, _errors : PhantomData } ;
49
47
50
48
value. try_fold_with ( & mut folder)
51
49
}
52
50
53
- struct NormalizationFolder < ' me , ' tcx , E : FulfillmentErrorLike < ' tcx > > {
51
+ struct NormalizationFolder < ' me , ' tcx , E > {
54
52
at : At < ' me , ' tcx > ,
55
53
fulfill_cx : FulfillmentCtxt < ' tcx , E > ,
56
54
depth : usize ,
57
55
universes : Vec < Option < UniverseIndex > > ,
58
56
_errors : PhantomData < E > ,
59
57
}
60
58
61
- impl < ' tcx , E : FromSolverError < ' tcx , NextSolverError < ' tcx > > > NormalizationFolder < ' _ , ' tcx , E > {
59
+ impl < ' tcx , E > NormalizationFolder < ' _ , ' tcx , E >
60
+ where
61
+ E : FromSolverError < ' tcx , NextSolverError < ' tcx > > ,
62
+ {
62
63
fn normalize_alias_ty ( & mut self , alias_ty : Ty < ' tcx > ) -> Result < Ty < ' tcx > , Vec < E > > {
63
64
assert ! ( matches!( alias_ty. kind( ) , ty:: Alias ( ..) ) ) ;
64
65
@@ -150,8 +151,9 @@ impl<'tcx, E: FromSolverError<'tcx, NextSolverError<'tcx>>> NormalizationFolder<
150
151
}
151
152
}
152
153
153
- impl < ' tcx , E : FromSolverError < ' tcx , NextSolverError < ' tcx > > > FallibleTypeFolder < TyCtxt < ' tcx > >
154
- for NormalizationFolder < ' _ , ' tcx , E >
154
+ impl < ' tcx , E > FallibleTypeFolder < TyCtxt < ' tcx > > for NormalizationFolder < ' _ , ' tcx , E >
155
+ where
156
+ E : FromSolverError < ' tcx , NextSolverError < ' tcx > > + Debug ,
155
157
{
156
158
type Error = Vec < E > ;
157
159
0 commit comments