@@ -16,26 +16,28 @@ use std::ops::ControlFlow;
16
16
/// useful for printing messages etc but also required at various
17
17
/// points for correctness.
18
18
pub struct OpportunisticVarResolver < ' a , ' tcx > {
19
- infcx : & ' a InferCtxt < ' tcx > ,
19
+ // The shallow resolver is used to resolve inference variables at every
20
+ // level of the type.
21
+ shallow_resolver : crate :: infer:: ShallowResolver < ' a , ' tcx > ,
20
22
}
21
23
22
24
impl < ' a , ' tcx > OpportunisticVarResolver < ' a , ' tcx > {
23
25
#[ inline]
24
26
pub fn new ( infcx : & ' a InferCtxt < ' tcx > ) -> Self {
25
- OpportunisticVarResolver { infcx }
27
+ OpportunisticVarResolver { shallow_resolver : crate :: infer :: ShallowResolver { infcx } }
26
28
}
27
29
}
28
30
29
31
impl < ' a , ' tcx > TypeFolder < ' tcx > for OpportunisticVarResolver < ' a , ' tcx > {
30
32
fn tcx < ' b > ( & ' b self ) -> TyCtxt < ' tcx > {
31
- self . infcx . tcx
33
+ TypeFolder :: tcx ( & self . shallow_resolver )
32
34
}
33
35
34
36
fn fold_ty ( & mut self , t : Ty < ' tcx > ) -> Ty < ' tcx > {
35
37
if !t. has_non_region_infer ( ) {
36
38
t // micro-optimize -- if there is nothing in this type that this fold affects...
37
39
} else {
38
- let t = self . infcx . shallow_resolve ( t) ;
40
+ let t = self . shallow_resolver . fold_ty ( t) ;
39
41
t. super_fold_with ( self )
40
42
}
41
43
}
@@ -44,7 +46,7 @@ impl<'a, 'tcx> TypeFolder<'tcx> for OpportunisticVarResolver<'a, 'tcx> {
44
46
if !ct. has_non_region_infer ( ) {
45
47
ct // micro-optimize -- if there is nothing in this const that this fold affects...
46
48
} else {
47
- let ct = self . infcx . shallow_resolve ( ct) ;
49
+ let ct = self . shallow_resolver . fold_const ( ct) ;
48
50
ct. super_fold_with ( self )
49
51
}
50
52
}
0 commit comments