@@ -14,6 +14,7 @@ use crate::solve::{
14
14
inspect, response_no_constraints_raw, CanonicalResponse , QueryResult , Response ,
15
15
} ;
16
16
use rustc_data_structures:: fx:: FxHashSet ;
17
+ use rustc_hir:: def_id:: LocalDefId ;
17
18
use rustc_index:: IndexVec ;
18
19
use rustc_infer:: infer:: canonical:: query_response:: make_query_region_constraints;
19
20
use rustc_infer:: infer:: canonical:: { CanonicalExt , QueryRegionConstraints } ;
@@ -178,8 +179,8 @@ impl<'tcx> EvalCtxt<'_, InferCtxt<'tcx>> {
178
179
fn compute_external_query_constraints (
179
180
& self ,
180
181
certainty : Certainty ,
181
- normalization_nested_goals : NestedNormalizationGoals < ' tcx > ,
182
- ) -> ExternalConstraintsData < ' tcx > {
182
+ normalization_nested_goals : NestedNormalizationGoals < TyCtxt < ' tcx > > ,
183
+ ) -> ExternalConstraintsData < TyCtxt < ' tcx > > {
183
184
// We only return region constraints once the certainty is `Yes`. This
184
185
// is necessary as we may drop nested goals on ambiguity, which may result
185
186
// in unconstrained inference variables in the region constraints. It also
@@ -213,13 +214,20 @@ impl<'tcx> EvalCtxt<'_, InferCtxt<'tcx>> {
213
214
Default :: default ( )
214
215
} ;
215
216
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
+ }
223
231
}
224
232
225
233
/// After calling a canonical query, we apply the constraints returned
@@ -235,7 +243,7 @@ impl<'tcx> EvalCtxt<'_, InferCtxt<'tcx>> {
235
243
param_env : ty:: ParamEnv < ' tcx > ,
236
244
original_values : Vec < ty:: GenericArg < ' tcx > > ,
237
245
response : CanonicalResponse < ' tcx > ,
238
- ) -> ( NestedNormalizationGoals < ' tcx > , Certainty ) {
246
+ ) -> ( NestedNormalizationGoals < TyCtxt < ' tcx > > , Certainty ) {
239
247
let instantiation = Self :: compute_query_response_instantiation_values (
240
248
self . infcx ,
241
249
& original_values,
@@ -385,10 +393,14 @@ impl<'tcx> EvalCtxt<'_, InferCtxt<'tcx>> {
385
393
}
386
394
}
387
395
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 {
390
401
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) ;
392
404
}
393
405
}
394
406
}
0 commit comments