@@ -61,8 +61,27 @@ impl<'cx, 'tcx> QueryNormalizeExt<'tcx> for At<'cx, 'tcx> {
61
61
self . cause,
62
62
) ;
63
63
64
+ // This is actually a consequence by the way `normalize_erasing_regions` works currently.
65
+ // Because it needs to call the `normalize_generic_arg_after_erasing_regions`, it folds
66
+ // through tys and consts in a `TypeFoldable`. Importantly, it skips binders, leaving us
67
+ // with trying to normalize with escaping bound vars.
68
+ //
69
+ // Here, we just add the universes that we *would* have created had we passed through the binders.
70
+ //
71
+ // We *could* replace escaping bound vars eagerly here, but it doesn't seem really necessary.
72
+ // The rest of the code is already set up to be lazy about replacing bound vars,
73
+ // and only when we actually have to normalize.
74
+ let universes = if value. has_escaping_bound_vars ( ) {
75
+ let mut max_visitor =
76
+ MaxEscapingBoundVarVisitor { outer_index : ty:: INNERMOST , escaping : 0 } ;
77
+ value. visit_with ( & mut max_visitor) ;
78
+ vec ! [ None ; max_visitor. escaping]
79
+ } else {
80
+ vec ! [ ]
81
+ } ;
82
+
64
83
if self . infcx . next_trait_solver ( ) {
65
- match crate :: solve:: deeply_normalize ( self , value) {
84
+ match crate :: solve:: deeply_normalize_with_skipped_universes ( self , value, universes ) {
66
85
Ok ( value) => return Ok ( Normalized { value, obligations : vec ! [ ] } ) ,
67
86
Err ( _errors) => {
68
87
return Err ( NoSolution ) ;
@@ -81,27 +100,9 @@ impl<'cx, 'tcx> QueryNormalizeExt<'tcx> for At<'cx, 'tcx> {
81
100
obligations : vec ! [ ] ,
82
101
cache : SsoHashMap :: new ( ) ,
83
102
anon_depth : 0 ,
84
- universes : vec ! [ ] ,
103
+ universes,
85
104
} ;
86
105
87
- // This is actually a consequence by the way `normalize_erasing_regions` works currently.
88
- // Because it needs to call the `normalize_generic_arg_after_erasing_regions`, it folds
89
- // through tys and consts in a `TypeFoldable`. Importantly, it skips binders, leaving us
90
- // with trying to normalize with escaping bound vars.
91
- //
92
- // Here, we just add the universes that we *would* have created had we passed through the binders.
93
- //
94
- // We *could* replace escaping bound vars eagerly here, but it doesn't seem really necessary.
95
- // The rest of the code is already set up to be lazy about replacing bound vars,
96
- // and only when we actually have to normalize.
97
- if value. has_escaping_bound_vars ( ) {
98
- let mut max_visitor =
99
- MaxEscapingBoundVarVisitor { outer_index : ty:: INNERMOST , escaping : 0 } ;
100
- value. visit_with ( & mut max_visitor) ;
101
- if max_visitor. escaping > 0 {
102
- normalizer. universes . extend ( ( 0 ..max_visitor. escaping ) . map ( |_| None ) ) ;
103
- }
104
- }
105
106
let result = value. try_fold_with ( & mut normalizer) ;
106
107
info ! (
107
108
"normalize::<{}>: result={:?} with {} obligations" ,
0 commit comments