@@ -86,20 +86,11 @@ impl<'a, D: SolverDelegate<Interner = I>, I: Interner> Canonicalizer<'a, D, I> {
8686 Canonical { max_universe, variables, value }
8787 }
8888
89- /// When canonicalizing query inputs, we keep `'static` in the `param_env`
90- /// but erase it everywhere else. We generally don't want to depend on region
91- /// identity, so while it should not matter whether `'static` is kept in the
92- /// value or opaque type storage as well, this prevents us from accidentally
93- /// relying on it in the future.
94- ///
95- /// We want to keep the option of canonicalizing `'static` to an existential
96- /// variable in the future by changing the way we detect global where-bounds.
97- pub fn canonicalize_input < P : TypeFoldable < I > > (
89+ fn canonicalize_param_env (
9890 delegate : & ' a D ,
9991 variables : & ' a mut Vec < I :: GenericArg > ,
100- input : QueryInput < I , P > ,
101- ) -> ty:: Canonical < I , QueryInput < I , P > > {
102- // First canonicalize the `param_env` while keeping `'static`
92+ param_env : I :: ParamEnv ,
93+ ) -> ( I :: ParamEnv , HashMap < I :: GenericArg , usize > , Vec < CanonicalVarKind < I > > ) {
10394 let mut env_canonicalizer = Canonicalizer {
10495 delegate,
10596 canonicalize_mode : CanonicalizeMode :: Input { keep_static : true } ,
@@ -111,19 +102,36 @@ impl<'a, D: SolverDelegate<Interner = I>, I: Interner> Canonicalizer<'a, D, I> {
111102
112103 cache : Default :: default ( ) ,
113104 } ;
114- let param_env = input . goal . param_env . fold_with ( & mut env_canonicalizer) ;
105+ let param_env = param_env. fold_with ( & mut env_canonicalizer) ;
115106 debug_assert_eq ! ( env_canonicalizer. binder_index, ty:: INNERMOST ) ;
107+ ( param_env, env_canonicalizer. variable_lookup_table , env_canonicalizer. var_kinds )
108+ }
109+
110+ /// When canonicalizing query inputs, we keep `'static` in the `param_env`
111+ /// but erase it everywhere else. We generally don't want to depend on region
112+ /// identity, so while it should not matter whether `'static` is kept in the
113+ /// value or opaque type storage as well, this prevents us from accidentally
114+ /// relying on it in the future.
115+ ///
116+ /// We want to keep the option of canonicalizing `'static` to an existential
117+ /// variable in the future by changing the way we detect global where-bounds.
118+ pub fn canonicalize_input < P : TypeFoldable < I > > (
119+ delegate : & ' a D ,
120+ variables : & ' a mut Vec < I :: GenericArg > ,
121+ input : QueryInput < I , P > ,
122+ ) -> ty:: Canonical < I , QueryInput < I , P > > {
123+ // First canonicalize the `param_env` while keeping `'static`
124+ let ( param_env, variable_lookup_table, var_kinds) =
125+ Canonicalizer :: canonicalize_param_env ( delegate, variables, input. goal . param_env ) ;
116126 // Then canonicalize the rest of the input without keeping `'static`
117127 // while *mostly* reusing the canonicalizer from above.
118128 let mut rest_canonicalizer = Canonicalizer {
119129 delegate,
120130 canonicalize_mode : CanonicalizeMode :: Input { keep_static : false } ,
121131
122- variables : env_canonicalizer. variables ,
123- // We're able to reuse the `variable_lookup_table` as whether or not
124- // it already contains an entry for `'static` does not matter.
125- variable_lookup_table : env_canonicalizer. variable_lookup_table ,
126- var_kinds : env_canonicalizer. var_kinds ,
132+ variables,
133+ variable_lookup_table,
134+ var_kinds,
127135 binder_index : ty:: INNERMOST ,
128136
129137 // We do not reuse the cache as it may contain entries whose canonicalized
0 commit comments