@@ -35,7 +35,7 @@ use rustc_infer::infer::{
3535} ;
3636use rustc_middle:: mir:: * ;
3737use rustc_middle:: query:: Providers ;
38- use rustc_middle:: ty:: { self , ParamEnv , RegionVid , TyCtxt , TypingMode , fold_regions } ;
38+ use rustc_middle:: ty:: { self , ParamEnv , RegionVid , TyCtxt , TypingMode } ;
3939use rustc_middle:: { bug, span_bug} ;
4040use rustc_mir_dataflow:: impls:: {
4141 EverInitializedPlaces , MaybeInitializedPlaces , MaybeUninitializedPlaces ,
@@ -171,12 +171,6 @@ fn do_mir_borrowck<'tcx>(
171171 let free_regions = nll:: replace_regions_in_mir ( & infcx, & mut body_owned, & mut promoted) ;
172172 let body = & body_owned; // no further changes
173173
174- // FIXME(-Znext-solver): A bit dubious that we're only registering
175- // predefined opaques in the typeck root.
176- if infcx. next_trait_solver ( ) && !infcx. tcx . is_typeck_child ( body. source . def_id ( ) ) {
177- infcx. register_predefined_opaques_for_next_solver ( def) ;
178- }
179-
180174 let location_table = PoloniusLocationTable :: new ( body) ;
181175
182176 let move_data = MoveData :: gather_moves ( body, tcx, |_| true ) ;
@@ -431,7 +425,12 @@ pub(crate) struct BorrowckInferCtxt<'tcx> {
431425
432426impl < ' tcx > BorrowckInferCtxt < ' tcx > {
433427 pub ( crate ) fn new ( tcx : TyCtxt < ' tcx > , def_id : LocalDefId ) -> Self {
434- let infcx = tcx. infer_ctxt ( ) . build ( TypingMode :: analysis_in_body ( tcx, def_id) ) ;
428+ let typing_mode = if tcx. use_typing_mode_borrowck ( ) {
429+ TypingMode :: borrowck ( tcx, def_id)
430+ } else {
431+ TypingMode :: analysis_in_body ( tcx, def_id)
432+ } ;
433+ let infcx = tcx. infer_ctxt ( ) . build ( typing_mode) ;
435434 let param_env = tcx. param_env ( def_id) ;
436435 BorrowckInferCtxt { infcx, reg_var_to_origin : RefCell :: new ( Default :: default ( ) ) , param_env }
437436 }
@@ -478,29 +477,6 @@ impl<'tcx> BorrowckInferCtxt<'tcx> {
478477
479478 next_region
480479 }
481-
482- /// With the new solver we prepopulate the opaque type storage during
483- /// MIR borrowck with the hidden types from HIR typeck. This is necessary
484- /// to avoid ambiguities as earlier goals can rely on the hidden type
485- /// of an opaque which is only constrained by a later goal.
486- fn register_predefined_opaques_for_next_solver ( & self , def_id : LocalDefId ) {
487- let tcx = self . tcx ;
488- // OK to use the identity arguments for each opaque type key, since
489- // we remap opaques from HIR typeck back to their definition params.
490- for data in tcx. typeck ( def_id) . concrete_opaque_types . iter ( ) . map ( |( k, v) | ( * k, * v) ) {
491- // HIR typeck did not infer the regions of the opaque, so we instantiate
492- // them with fresh inference variables.
493- let ( key, hidden_ty) = fold_regions ( tcx, data, |_, _| {
494- self . next_nll_region_var_in_universe (
495- NllRegionVariableOrigin :: Existential { from_forall : false } ,
496- ty:: UniverseIndex :: ROOT ,
497- )
498- } ) ;
499-
500- let prev = self . register_hidden_type_in_storage ( key, hidden_ty) ;
501- assert_eq ! ( prev, None ) ;
502- }
503- }
504480}
505481
506482impl < ' tcx > Deref for BorrowckInferCtxt < ' tcx > {
0 commit comments