@@ -100,20 +100,15 @@ impl<'a, D: SolverDelegate<Interner = I>, I: Interner> Canonicalizer<'a, D, I> {
100
100
Canonical { max_universe, variables, value }
101
101
}
102
102
103
- /// When canonicalizing query inputs, we keep `'static` in the `param_env`
104
- /// but erase it everywhere else. We generally don't want to depend on region
105
- /// identity, so while it should not matter whether `'static` is kept in the
106
- /// value or opaque type storage as well, this prevents us from accidentally
107
- /// relying on it in the future.
108
- ///
109
- /// We want to keep the option of canonicalizing `'static` to an existential
110
- /// variable in the future by changing the way we detect global where-bounds.
111
- pub fn canonicalize_input < P : TypeFoldable < I > > (
103
+ fn canonicalize_param_env (
112
104
delegate : & ' a D ,
113
105
variables : & ' a mut Vec < I :: GenericArg > ,
114
- input : QueryInput < I , P > ,
115
- ) -> ty:: Canonical < I , QueryInput < I , P > > {
116
- // First canonicalize the `param_env` while keeping `'static`
106
+ param_env : I :: ParamEnv ,
107
+ ) -> ( I :: ParamEnv , HashMap < I :: GenericArg , usize > , Vec < CanonicalVarKind < I > > ) {
108
+ if !param_env. has_type_flags ( NEEDS_CANONICAL ) {
109
+ return ( param_env, Default :: default ( ) , Vec :: new ( ) ) ;
110
+ }
111
+
117
112
let mut env_canonicalizer = Canonicalizer {
118
113
delegate,
119
114
canonicalize_mode : CanonicalizeMode :: Input { keep_static : true } ,
@@ -125,26 +120,36 @@ impl<'a, D: SolverDelegate<Interner = I>, I: Interner> Canonicalizer<'a, D, I> {
125
120
126
121
cache : Default :: default ( ) ,
127
122
} ;
128
-
129
- let param_env = input. goal . param_env ;
130
- let param_env = if param_env. has_type_flags ( NEEDS_CANONICAL ) {
131
- param_env. fold_with ( & mut env_canonicalizer)
132
- } else {
133
- param_env
134
- } ;
135
-
123
+ let param_env = param_env. fold_with ( & mut env_canonicalizer) ;
136
124
debug_assert_eq ! ( env_canonicalizer. binder_index, ty:: INNERMOST ) ;
125
+ ( param_env, env_canonicalizer. variable_lookup_table , env_canonicalizer. var_kinds )
126
+ }
127
+
128
+ /// When canonicalizing query inputs, we keep `'static` in the `param_env`
129
+ /// but erase it everywhere else. We generally don't want to depend on region
130
+ /// identity, so while it should not matter whether `'static` is kept in the
131
+ /// value or opaque type storage as well, this prevents us from accidentally
132
+ /// relying on it in the future.
133
+ ///
134
+ /// We want to keep the option of canonicalizing `'static` to an existential
135
+ /// variable in the future by changing the way we detect global where-bounds.
136
+ pub fn canonicalize_input < P : TypeFoldable < I > > (
137
+ delegate : & ' a D ,
138
+ variables : & ' a mut Vec < I :: GenericArg > ,
139
+ input : QueryInput < I , P > ,
140
+ ) -> ty:: Canonical < I , QueryInput < I , P > > {
141
+ // First canonicalize the `param_env` while keeping `'static`
142
+ let ( param_env, variable_lookup_table, var_kinds) =
143
+ Canonicalizer :: canonicalize_param_env ( delegate, variables, input. goal . param_env ) ;
137
144
// Then canonicalize the rest of the input without keeping `'static`
138
145
// while *mostly* reusing the canonicalizer from above.
139
146
let mut rest_canonicalizer = Canonicalizer {
140
147
delegate,
141
148
canonicalize_mode : CanonicalizeMode :: Input { keep_static : false } ,
142
149
143
- variables : env_canonicalizer. variables ,
144
- // We're able to reuse the `variable_lookup_table` as whether or not
145
- // it already contains an entry for `'static` does not matter.
146
- variable_lookup_table : env_canonicalizer. variable_lookup_table ,
147
- var_kinds : env_canonicalizer. var_kinds ,
150
+ variables,
151
+ variable_lookup_table,
152
+ var_kinds,
148
153
binder_index : ty:: INNERMOST ,
149
154
150
155
// We do not reuse the cache as it may contain entries whose canonicalized
0 commit comments