@@ -41,7 +41,33 @@ impl<'tcx> InferCtxt<'tcx> {
4141 where
4242 V : TypeFoldable < TyCtxt < ' tcx > > ,
4343 {
44- self . canonicalize_query_with_mode ( value, query_state, & CanonicalizeAllFreeRegions )
44+ let ( param_env, value) = value. into_parts ( ) ;
45+ let param_env = self . tcx . canonical_param_env_cache . get_or_insert (
46+ self . tcx ,
47+ param_env,
48+ query_state,
49+ |tcx, param_env, query_state| {
50+ // FIXME(#118965): We don't canonicalize the static lifetimes that appear in the
51+ // `param_env` beacause they are treated differently by trait selection.
52+ Canonicalizer :: canonicalize (
53+ param_env,
54+ None ,
55+ tcx,
56+ & CanonicalizeFreeRegionsOtherThanStatic ,
57+ query_state,
58+ )
59+ } ,
60+ ) ;
61+
62+ Canonicalizer :: canonicalize_with_base (
63+ param_env,
64+ value,
65+ Some ( self ) ,
66+ self . tcx ,
67+ & CanonicalizeAllFreeRegions ,
68+ query_state,
69+ )
70+ . unchecked_map ( |( param_env, value) | param_env. and ( value) )
4571 }
4672
4773 /// Canonicalizes a query *response* `V`. When we canonicalize a
@@ -96,61 +122,6 @@ impl<'tcx> InferCtxt<'tcx> {
96122 & mut query_state,
97123 )
98124 }
99-
100- /// A variant of `canonicalize_query` that does not
101- /// canonicalize `'static`. This is useful when
102- /// the query implementation can perform more efficient
103- /// handling of `'static` regions (e.g. trait evaluation).
104- pub fn canonicalize_query_keep_static < V > (
105- & self ,
106- value : ty:: ParamEnvAnd < ' tcx , V > ,
107- query_state : & mut OriginalQueryValues < ' tcx > ,
108- ) -> Canonical < ' tcx , ty:: ParamEnvAnd < ' tcx , V > >
109- where
110- V : TypeFoldable < TyCtxt < ' tcx > > ,
111- {
112- self . canonicalize_query_with_mode (
113- value,
114- query_state,
115- & CanonicalizeFreeRegionsOtherThanStatic ,
116- )
117- }
118-
119- fn canonicalize_query_with_mode < V > (
120- & self ,
121- value : ty:: ParamEnvAnd < ' tcx , V > ,
122- query_state : & mut OriginalQueryValues < ' tcx > ,
123- canonicalize_region_mode : & dyn CanonicalizeMode ,
124- ) -> Canonical < ' tcx , ty:: ParamEnvAnd < ' tcx , V > >
125- where
126- V : TypeFoldable < TyCtxt < ' tcx > > ,
127- {
128- let ( param_env, value) = value. into_parts ( ) ;
129- let base = self . tcx . canonical_param_env_cache . get_or_insert (
130- self . tcx ,
131- param_env,
132- query_state,
133- |tcx, param_env, query_state| {
134- Canonicalizer :: canonicalize (
135- param_env,
136- None ,
137- tcx,
138- & CanonicalizeFreeRegionsOtherThanStatic ,
139- query_state,
140- )
141- } ,
142- ) ;
143-
144- Canonicalizer :: canonicalize_with_base (
145- base,
146- value,
147- Some ( self ) ,
148- self . tcx ,
149- canonicalize_region_mode,
150- query_state,
151- )
152- . unchecked_map ( |( param_env, value) | param_env. and ( value) )
153- }
154125}
155126
156127/// Controls how we canonicalize "free regions" that are not inference
0 commit comments