@@ -200,46 +200,8 @@ pub(crate) fn type_check<'mir, 'tcx>(
200
200
) ;
201
201
202
202
translate_outlives_facts ( & mut cx) ;
203
- let opaque_type_values =
204
- infcx. inner . borrow_mut ( ) . opaque_type_storage . take_opaque_types ( ) ;
205
-
206
- opaque_type_values
207
- . into_iter ( )
208
- . map ( |( opaque_type_key, decl) | {
209
- cx. fully_perform_op (
210
- Locations :: All ( body. span ) ,
211
- ConstraintCategory :: OpaqueType ,
212
- CustomTypeOp :: new (
213
- |infcx| {
214
- infcx. register_member_constraints (
215
- param_env,
216
- opaque_type_key,
217
- decl. hidden_type . ty ,
218
- decl. hidden_type . span ,
219
- ) ;
220
- Ok ( InferOk { value : ( ) , obligations : vec ! [ ] } )
221
- } ,
222
- || "opaque_type_map" . to_string ( ) ,
223
- ) ,
224
- )
225
- . unwrap ( ) ;
226
- let mut hidden_type = infcx. resolve_vars_if_possible ( decl. hidden_type ) ;
227
- trace ! (
228
- "finalized opaque type {:?} to {:#?}" ,
229
- opaque_type_key,
230
- hidden_type. ty. kind( )
231
- ) ;
232
- if hidden_type. has_infer_types_or_consts ( ) {
233
- infcx. tcx . sess . delay_span_bug (
234
- decl. hidden_type . span ,
235
- & format ! ( "could not resolve {:#?}" , hidden_type. ty. kind( ) ) ,
236
- ) ;
237
- hidden_type. ty = infcx. tcx . ty_error ( ) ;
238
- }
239
203
240
- ( opaque_type_key, ( hidden_type, decl. origin ) )
241
- } )
242
- . collect ( )
204
+ cx. finalize_opaque_types ( )
243
205
} ,
244
206
) ;
245
207
@@ -2680,6 +2642,54 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
2680
2642
self . check_iscleanup ( & body, block_data) ;
2681
2643
}
2682
2644
}
2645
+
2646
+ /// Generates member constraints for the opaque types found so far.
2647
+ /// Returns a map to their hidden types.
2648
+ fn finalize_opaque_types (
2649
+ & mut self ,
2650
+ ) -> VecMap < OpaqueTypeKey < ' tcx > , ( OpaqueHiddenType < ' tcx > , OpaqueTyOrigin ) > {
2651
+ let opaque_type_values =
2652
+ self . infcx . inner . borrow_mut ( ) . opaque_type_storage . take_opaque_types ( ) ;
2653
+
2654
+ opaque_type_values
2655
+ . into_iter ( )
2656
+ . map ( |( opaque_type_key, decl) | {
2657
+ let param_env = self . param_env ;
2658
+ self . fully_perform_op (
2659
+ Locations :: All ( self . body . span ) ,
2660
+ ConstraintCategory :: OpaqueType ,
2661
+ CustomTypeOp :: new (
2662
+ |infcx| {
2663
+ infcx. register_member_constraints (
2664
+ param_env,
2665
+ opaque_type_key,
2666
+ decl. hidden_type . ty ,
2667
+ decl. hidden_type . span ,
2668
+ ) ;
2669
+ Ok ( InferOk { value : ( ) , obligations : vec ! [ ] } )
2670
+ } ,
2671
+ || "opaque_type_map" . to_string ( ) ,
2672
+ ) ,
2673
+ )
2674
+ . unwrap ( ) ;
2675
+ let mut hidden_type = self . infcx . resolve_vars_if_possible ( decl. hidden_type ) ;
2676
+ trace ! (
2677
+ "finalized opaque type {:?} to {:#?}" ,
2678
+ opaque_type_key,
2679
+ hidden_type. ty. kind( )
2680
+ ) ;
2681
+ if hidden_type. has_infer_types_or_consts ( ) {
2682
+ self . infcx . tcx . sess . delay_span_bug (
2683
+ decl. hidden_type . span ,
2684
+ & format ! ( "could not resolve {:#?}" , hidden_type. ty. kind( ) ) ,
2685
+ ) ;
2686
+ hidden_type. ty = self . infcx . tcx . ty_error ( ) ;
2687
+ }
2688
+
2689
+ ( opaque_type_key, ( hidden_type, decl. origin ) )
2690
+ } )
2691
+ . collect ( )
2692
+ }
2683
2693
}
2684
2694
2685
2695
trait NormalizeLocation : fmt:: Debug + Copy {
0 commit comments