@@ -3,6 +3,7 @@ use rustc_data_structures::vec_map::VecMap;
33use rustc_hir:: def_id:: LocalDefId ;
44use rustc_hir:: OpaqueTyOrigin ;
55use rustc_infer:: infer:: error_reporting:: unexpected_hidden_region_diagnostic;
6+ use rustc_infer:: infer:: opaque_types:: OpaqueTypeMap ;
67use rustc_infer:: infer:: TyCtxtInferExt as _;
78use rustc_infer:: infer:: { DefiningAnchor , InferCtxt } ;
89use rustc_infer:: traits:: { Obligation , ObligationCause , TraitEngine } ;
@@ -62,12 +63,12 @@ impl<'tcx> RegionInferenceContext<'tcx> {
6263 pub ( crate ) fn infer_opaque_types (
6364 & self ,
6465 infcx : & InferCtxt < ' _ , ' tcx > ,
65- opaque_ty_decls : VecMap < OpaqueTypeKey < ' tcx > , ( OpaqueHiddenType < ' tcx > , OpaqueTyOrigin ) > ,
66+ opaque_ty_decls : OpaqueTypeMap < ' tcx > ,
6667 ) -> VecMap < LocalDefId , OpaqueHiddenType < ' tcx > > {
6768 let mut result: VecMap < LocalDefId , OpaqueHiddenType < ' tcx > > = VecMap :: new ( ) ;
68- for ( opaque_type_key, ( concrete_type , origin ) ) in opaque_ty_decls {
69+ for ( opaque_type_key, decl ) in opaque_ty_decls {
6970 let substs = opaque_type_key. substs ;
70- debug ! ( ?concrete_type , ?substs) ;
71+ debug ! ( ?decl . hidden_type , ?substs) ;
7172
7273 let mut subst_regions = vec ! [ self . universal_regions. fr_static] ;
7374 let universal_substs = infcx. tcx . fold_regions ( substs, |region, _| {
@@ -90,7 +91,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
9091 None => {
9192 subst_regions. push ( vid) ;
9293 infcx. tcx . sess . delay_span_bug (
93- concrete_type . span ,
94+ decl . hidden_type . span ,
9495 "opaque type with non-universal region substs" ,
9596 ) ;
9697 infcx. tcx . lifetimes . re_static
@@ -102,7 +103,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
102103 subst_regions. dedup ( ) ;
103104
104105 let universal_concrete_type =
105- infcx. tcx . fold_regions ( concrete_type , |region, _| match * region {
106+ infcx. tcx . fold_regions ( decl . hidden_type , |region, _| match * region {
106107 ty:: ReVar ( vid) => subst_regions
107108 . iter ( )
108109 . find ( |ur_vid| self . eval_equal ( vid, * * ur_vid) )
@@ -118,7 +119,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
118119 let ty = infcx. infer_opaque_definition_from_instantiation (
119120 opaque_type_key,
120121 universal_concrete_type,
121- origin,
122+ decl . origin ,
122123 ) ;
123124 // Sometimes two opaque types are the same only after we remap the generic parameters
124125 // back to the opaque type definition. E.g. we may have `OpaqueType<X, Y>` mapped to `(X, Y)`
@@ -128,19 +129,19 @@ impl<'tcx> RegionInferenceContext<'tcx> {
128129 if prev. ty != ty {
129130 if !ty. references_error ( ) {
130131 prev. report_mismatch (
131- & OpaqueHiddenType { ty, span : concrete_type . span } ,
132+ & OpaqueHiddenType { ty, span : decl . hidden_type . span } ,
132133 infcx. tcx ,
133134 ) ;
134135 }
135136 prev. ty = infcx. tcx . ty_error ( ) ;
136137 }
137138 // Pick a better span if there is one.
138139 // FIXME(oli-obk): collect multiple spans for better diagnostics down the road.
139- prev. span = prev. span . substitute_dummy ( concrete_type . span ) ;
140+ prev. span = prev. span . substitute_dummy ( decl . hidden_type . span ) ;
140141 } else {
141142 result. insert (
142143 opaque_type_key. def_id ,
143- OpaqueHiddenType { ty, span : concrete_type . span } ,
144+ OpaqueHiddenType { ty, span : decl . hidden_type . span } ,
144145 ) ;
145146 }
146147 }
0 commit comments