@@ -3,6 +3,7 @@ use rustc_data_structures::vec_map::VecMap;
3
3
use rustc_hir:: def_id:: LocalDefId ;
4
4
use rustc_hir:: OpaqueTyOrigin ;
5
5
use rustc_infer:: infer:: error_reporting:: unexpected_hidden_region_diagnostic;
6
+ use rustc_infer:: infer:: opaque_types:: OpaqueTypeMap ;
6
7
use rustc_infer:: infer:: TyCtxtInferExt as _;
7
8
use rustc_infer:: infer:: { DefiningAnchor , InferCtxt } ;
8
9
use rustc_infer:: traits:: { Obligation , ObligationCause , TraitEngine } ;
@@ -62,12 +63,12 @@ impl<'tcx> RegionInferenceContext<'tcx> {
62
63
pub ( crate ) fn infer_opaque_types (
63
64
& self ,
64
65
infcx : & InferCtxt < ' _ , ' tcx > ,
65
- opaque_ty_decls : VecMap < OpaqueTypeKey < ' tcx > , ( OpaqueHiddenType < ' tcx > , OpaqueTyOrigin ) > ,
66
+ opaque_ty_decls : OpaqueTypeMap < ' tcx > ,
66
67
) -> VecMap < LocalDefId , OpaqueHiddenType < ' tcx > > {
67
68
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 {
69
70
let substs = opaque_type_key. substs ;
70
- debug ! ( ?concrete_type , ?substs) ;
71
+ debug ! ( ?decl . hidden_type , ?substs) ;
71
72
72
73
let mut subst_regions = vec ! [ self . universal_regions. fr_static] ;
73
74
let universal_substs = infcx. tcx . fold_regions ( substs, |region, _| {
@@ -90,7 +91,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
90
91
None => {
91
92
subst_regions. push ( vid) ;
92
93
infcx. tcx . sess . delay_span_bug (
93
- concrete_type . span ,
94
+ decl . hidden_type . span ,
94
95
"opaque type with non-universal region substs" ,
95
96
) ;
96
97
infcx. tcx . lifetimes . re_static
@@ -102,7 +103,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
102
103
subst_regions. dedup ( ) ;
103
104
104
105
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 {
106
107
ty:: ReVar ( vid) => subst_regions
107
108
. iter ( )
108
109
. find ( |ur_vid| self . eval_equal ( vid, * * ur_vid) )
@@ -118,7 +119,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
118
119
let ty = infcx. infer_opaque_definition_from_instantiation (
119
120
opaque_type_key,
120
121
universal_concrete_type,
121
- origin,
122
+ decl . origin ,
122
123
) ;
123
124
// Sometimes two opaque types are the same only after we remap the generic parameters
124
125
// 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> {
128
129
if prev. ty != ty {
129
130
if !ty. references_error ( ) {
130
131
prev. report_mismatch (
131
- & OpaqueHiddenType { ty, span : concrete_type . span } ,
132
+ & OpaqueHiddenType { ty, span : decl . hidden_type . span } ,
132
133
infcx. tcx ,
133
134
) ;
134
135
}
135
136
prev. ty = infcx. tcx . ty_error ( ) ;
136
137
}
137
138
// Pick a better span if there is one.
138
139
// 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 ) ;
140
141
} else {
141
142
result. insert (
142
143
opaque_type_key. def_id ,
143
- OpaqueHiddenType { ty, span : concrete_type . span } ,
144
+ OpaqueHiddenType { ty, span : decl . hidden_type . span } ,
144
145
) ;
145
146
}
146
147
}
0 commit comments