@@ -17,7 +17,7 @@ use rustc_span::Span;
1717
1818use std:: ops:: ControlFlow ;
1919
20- pub type OpaqueTypeMap < ' tcx > = VecMap < DefId , OpaqueTypeDecl < ' tcx > > ;
20+ pub type OpaqueTypeMap < ' tcx > = VecMap < OpaqueTypeKey < ' tcx > , OpaqueTypeDecl < ' tcx > > ;
2121
2222/// Information about the opaque types whose values we
2323/// are inferring in this function (these are the `impl Trait` that
@@ -370,7 +370,8 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
370370 ) {
371371 debug ! ( "constrain_opaque_types()" ) ;
372372
373- for & ( def_id, opaque_defn) in opaque_types {
373+ for & ( opaque_type_key, opaque_defn) in opaque_types {
374+ let OpaqueTypeKey { def_id, substs : _ } = opaque_type_key;
374375 self . constrain_opaque_type (
375376 def_id,
376377 & opaque_defn,
@@ -1041,7 +1042,12 @@ impl<'a, 'tcx> Instantiator<'a, 'tcx> {
10411042
10421043 // Use the same type variable if the exact same opaque type appears more
10431044 // than once in the return type (e.g., if it's passed to a type alias).
1044- if let Some ( opaque_defn) = self . opaque_types . get ( & def_id) {
1045+ if let Some ( opaque_defn) = self
1046+ . opaque_types
1047+ . iter ( )
1048+ . find ( |( opaque_type_key, _) | opaque_type_key. def_id == def_id)
1049+ . map ( |( _, opaque_defn) | opaque_defn)
1050+ {
10451051 debug ! ( "instantiate_opaque_types: returning concrete ty {:?}" , opaque_defn. concrete_ty) ;
10461052 return opaque_defn. concrete_ty ;
10471053 }
@@ -1079,7 +1085,7 @@ impl<'a, 'tcx> Instantiator<'a, 'tcx> {
10791085 let definition_span = self . value_span ;
10801086
10811087 self . opaque_types . insert (
1082- def_id,
1088+ OpaqueTypeKey { def_id, substs } ,
10831089 OpaqueTypeDecl {
10841090 opaque_type : ty,
10851091 substs,
0 commit comments