@@ -14,6 +14,7 @@ use crate::solve::{
1414 inspect, response_no_constraints_raw, CanonicalResponse , QueryResult , Response ,
1515} ;
1616use rustc_data_structures:: fx:: FxHashSet ;
17+ use rustc_hir:: def_id:: LocalDefId ;
1718use rustc_index:: IndexVec ;
1819use rustc_infer:: infer:: canonical:: query_response:: make_query_region_constraints;
1920use rustc_infer:: infer:: canonical:: { CanonicalExt , QueryRegionConstraints } ;
@@ -178,8 +179,8 @@ impl<'tcx> EvalCtxt<'_, InferCtxt<'tcx>> {
178179 fn compute_external_query_constraints (
179180 & self ,
180181 certainty : Certainty ,
181- normalization_nested_goals : NestedNormalizationGoals < ' tcx > ,
182- ) -> ExternalConstraintsData < ' tcx > {
182+ normalization_nested_goals : NestedNormalizationGoals < TyCtxt < ' tcx > > ,
183+ ) -> ExternalConstraintsData < TyCtxt < ' tcx > > {
183184 // We only return region constraints once the certainty is `Yes`. This
184185 // is necessary as we may drop nested goals on ambiguity, which may result
185186 // in unconstrained inference variables in the region constraints. It also
@@ -213,13 +214,20 @@ impl<'tcx> EvalCtxt<'_, InferCtxt<'tcx>> {
213214 Default :: default ( )
214215 } ;
215216
216- let mut opaque_types = self . infcx . clone_opaque_types_for_query_response ( ) ;
217- // Only return opaque type keys for newly-defined opaques
218- opaque_types. retain ( |( a, _) | {
219- self . predefined_opaques_in_body . opaque_types . iter ( ) . all ( |( pa, _) | pa != a)
220- } ) ;
221-
222- ExternalConstraintsData { region_constraints, opaque_types, normalization_nested_goals }
217+ ExternalConstraintsData {
218+ region_constraints,
219+ opaque_types : self
220+ . infcx
221+ . clone_opaque_types_for_query_response ( )
222+ . into_iter ( )
223+ // Only return *newly defined* opaque types.
224+ . filter ( |( a, _) | {
225+ self . predefined_opaques_in_body . opaque_types . iter ( ) . all ( |( pa, _) | pa != a)
226+ } )
227+ . map ( |( key, value) | ( key. def_id , key. args , value) )
228+ . collect ( ) ,
229+ normalization_nested_goals,
230+ }
223231 }
224232
225233 /// After calling a canonical query, we apply the constraints returned
@@ -235,7 +243,7 @@ impl<'tcx> EvalCtxt<'_, InferCtxt<'tcx>> {
235243 param_env : ty:: ParamEnv < ' tcx > ,
236244 original_values : Vec < ty:: GenericArg < ' tcx > > ,
237245 response : CanonicalResponse < ' tcx > ,
238- ) -> ( NestedNormalizationGoals < ' tcx > , Certainty ) {
246+ ) -> ( NestedNormalizationGoals < TyCtxt < ' tcx > > , Certainty ) {
239247 let instantiation = Self :: compute_query_response_instantiation_values (
240248 self . infcx ,
241249 & original_values,
@@ -385,10 +393,14 @@ impl<'tcx> EvalCtxt<'_, InferCtxt<'tcx>> {
385393 }
386394 }
387395
388- fn register_new_opaque_types ( & mut self , opaque_types : & [ ( ty:: OpaqueTypeKey < ' tcx > , Ty < ' tcx > ) ] ) {
389- for & ( key, ty) in opaque_types {
396+ fn register_new_opaque_types (
397+ & mut self ,
398+ opaque_types : & [ ( LocalDefId , ty:: GenericArgsRef < ' tcx > , Ty < ' tcx > ) ] ,
399+ ) {
400+ for & ( def_id, args, ty) in opaque_types {
390401 let hidden_ty = ty:: OpaqueHiddenType { ty, span : DUMMY_SP } ;
391- self . infcx . inject_new_hidden_type_unchecked ( key, hidden_ty) ;
402+ self . infcx
403+ . inject_new_hidden_type_unchecked ( ty:: OpaqueTypeKey { def_id, args } , hidden_ty) ;
392404 }
393405 }
394406}
0 commit comments