@@ -40,9 +40,7 @@ use rustc_mir_dataflow::points::DenseLocationMap;
40
40
use rustc_span:: def_id:: CRATE_DEF_ID ;
41
41
use rustc_span:: source_map:: Spanned ;
42
42
use rustc_span:: { DUMMY_SP , Span , sym} ;
43
- use rustc_trait_selection:: traits:: query:: type_op:: custom:: {
44
- CustomTypeOp , scrape_region_constraints,
45
- } ;
43
+ use rustc_trait_selection:: traits:: query:: type_op:: custom:: scrape_region_constraints;
46
44
use rustc_trait_selection:: traits:: query:: type_op:: { TypeOp , TypeOpOutput } ;
47
45
use tracing:: { debug, instrument, trace} ;
48
46
@@ -89,6 +87,7 @@ mod constraint_conversion;
89
87
pub ( crate ) mod free_region_relations;
90
88
mod input_output;
91
89
pub ( crate ) mod liveness;
90
+ mod opaque_types;
92
91
mod relate_tys;
93
92
94
93
/// Type checks the given `mir` in the context of the inference
@@ -179,52 +178,8 @@ pub(crate) fn type_check<'a, 'tcx>(
179
178
180
179
liveness:: generate ( & mut typeck, body, & elements, flow_inits, move_data) ;
181
180
182
- let opaque_type_values = infcx
183
- . take_opaque_types ( )
184
- . into_iter ( )
185
- . map ( |( opaque_type_key, decl) | {
186
- let _: Result < _ , ErrorGuaranteed > = typeck. fully_perform_op (
187
- Locations :: All ( body. span ) ,
188
- ConstraintCategory :: OpaqueType ,
189
- CustomTypeOp :: new (
190
- |ocx| {
191
- ocx. infcx . register_member_constraints (
192
- opaque_type_key,
193
- decl. hidden_type . ty ,
194
- decl. hidden_type . span ,
195
- ) ;
196
- Ok ( ( ) )
197
- } ,
198
- "opaque_type_map" ,
199
- ) ,
200
- ) ;
201
- let hidden_type = infcx. resolve_vars_if_possible ( decl. hidden_type ) ;
202
- trace ! ( "finalized opaque type {:?} to {:#?}" , opaque_type_key, hidden_type. ty. kind( ) ) ;
203
- if hidden_type. has_non_region_infer ( ) {
204
- infcx. dcx ( ) . span_bug (
205
- decl. hidden_type . span ,
206
- format ! ( "could not resolve {:#?}" , hidden_type. ty. kind( ) ) ,
207
- ) ;
208
- }
209
-
210
- // Convert all regions to nll vars.
211
- let ( opaque_type_key, hidden_type) =
212
- fold_regions ( infcx. tcx , ( opaque_type_key, hidden_type) , |region, _| {
213
- match region. kind ( ) {
214
- ty:: ReVar ( _) => region,
215
- ty:: RePlaceholder ( placeholder) => {
216
- typeck. constraints . placeholder_region ( infcx, placeholder)
217
- }
218
- _ => ty:: Region :: new_var (
219
- infcx. tcx ,
220
- typeck. universal_regions . to_region_vid ( region) ,
221
- ) ,
222
- }
223
- } ) ;
224
-
225
- ( opaque_type_key, hidden_type)
226
- } )
227
- . collect ( ) ;
181
+ let opaque_type_values =
182
+ opaque_types:: take_opaques_and_register_member_constraints ( & mut typeck) ;
228
183
229
184
MirTypeckResults { constraints, universal_region_relations, opaque_type_values }
230
185
}
@@ -955,6 +910,14 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
955
910
self . body
956
911
}
957
912
913
+ fn to_region_vid ( & mut self , r : ty:: Region < ' tcx > ) -> RegionVid {
914
+ if let ty:: RePlaceholder ( placeholder) = r. kind ( ) {
915
+ self . constraints . placeholder_region ( self . infcx , placeholder) . as_var ( )
916
+ } else {
917
+ self . universal_regions . to_region_vid ( r)
918
+ }
919
+ }
920
+
958
921
fn unsized_feature_enabled ( & self ) -> bool {
959
922
let features = self . tcx ( ) . features ( ) ;
960
923
features. unsized_locals ( ) || features. unsized_fn_params ( )
0 commit comments