@@ -100,20 +100,15 @@ impl<'a, D: SolverDelegate<Interner = I>, I: Interner> Canonicalizer<'a, D, I> {
100100 Canonical { max_universe, variables, value }
101101 }
102102
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 (
112104 delegate : & ' a D ,
113105 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+
117112 let mut env_canonicalizer = Canonicalizer {
118113 delegate,
119114 canonicalize_mode : CanonicalizeMode :: Input { keep_static : true } ,
@@ -125,26 +120,36 @@ impl<'a, D: SolverDelegate<Interner = I>, I: Interner> Canonicalizer<'a, D, I> {
125120
126121 cache : Default :: default ( ) ,
127122 } ;
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) ;
136124 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 ) ;
137144 // Then canonicalize the rest of the input without keeping `'static`
138145 // while *mostly* reusing the canonicalizer from above.
139146 let mut rest_canonicalizer = Canonicalizer {
140147 delegate,
141148 canonicalize_mode : CanonicalizeMode :: Input { keep_static : false } ,
142149
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,
148153 binder_index : ty:: INNERMOST ,
149154
150155 // We do not reuse the cache as it may contain entries whose canonicalized
0 commit comments