@@ -24,17 +24,11 @@ use rustc_fluent_macro::fluent_messages;
2424use rustc_hir as hir;
2525use rustc_hir:: def_id:: LocalDefId ;
2626use rustc_index:: bit_set:: ChunkedBitSet ;
27- use rustc_index:: { IndexSlice , IndexVec } ;
27+ use rustc_index:: IndexVec ;
2828use rustc_infer:: infer:: {
2929 DefiningAnchor , InferCtxt , NllRegionVariableOrigin , RegionVariableOrigin , TyCtxtInferExt ,
3030} ;
31- use rustc_middle:: mir:: {
32- traversal, Body , ClearCrossCrate , Local , Location , Mutability , NonDivergingIntrinsic , Operand ,
33- Place , PlaceElem , PlaceRef , VarDebugInfoContents ,
34- } ;
35- use rustc_middle:: mir:: { AggregateKind , BasicBlock , BorrowCheckResult , BorrowKind } ;
36- use rustc_middle:: mir:: { InlineAsmOperand , Terminator , TerminatorKind } ;
37- use rustc_middle:: mir:: { ProjectionElem , Promoted , Rvalue , Statement , StatementKind } ;
31+ use rustc_middle:: mir:: * ;
3832use rustc_middle:: query:: Providers ;
3933use rustc_middle:: ty:: { self , CapturedPlace , ParamEnv , RegionVid , TyCtxt } ;
4034use rustc_session:: lint:: builtin:: UNUSED_MUT ;
@@ -123,7 +117,7 @@ pub fn provide(providers: &mut Providers) {
123117}
124118
125119fn mir_borrowck ( tcx : TyCtxt < ' _ > , def : LocalDefId ) -> & BorrowCheckResult < ' _ > {
126- let ( input_body, promoted ) = tcx. mir_promoted ( def) ;
120+ let ( input_body, _ ) = tcx. mir_promoted ( def) ;
127121 debug ! ( "run query mir_borrowck: {}" , tcx. def_path_str( def) ) ;
128122
129123 if input_body. borrow ( ) . should_skip ( ) {
@@ -138,13 +132,11 @@ fn mir_borrowck(tcx: TyCtxt<'_>, def: LocalDefId) -> &BorrowCheckResult<'_> {
138132 return tcx. arena . alloc ( result) ;
139133 }
140134
141- let hir_owner = tcx. hir ( ) . local_def_id_to_hir_id ( def) . owner ;
142-
135+ let typeck_root = tcx. typeck_root_def_id ( def. to_def_id ( ) ) . expect_local ( ) ;
143136 let infcx =
144- tcx. infer_ctxt ( ) . with_opaque_type_inference ( DefiningAnchor :: Bind ( hir_owner . def_id ) ) . build ( ) ;
137+ tcx. infer_ctxt ( ) . with_opaque_type_inference ( DefiningAnchor :: Bind ( typeck_root ) ) . build ( ) ;
145138 let input_body: & Body < ' _ > = & input_body. borrow ( ) ;
146- let promoted: & IndexSlice < _ , _ > = & promoted. borrow ( ) ;
147- let opt_closure_req = do_mir_borrowck ( & infcx, input_body, promoted, false ) . 0 ;
139+ let opt_closure_req = do_mir_borrowck ( & infcx, input_body, false ) . 0 ;
148140 debug ! ( "mir_borrowck done" ) ;
149141
150142 tcx. arena . alloc ( opt_closure_req)
@@ -155,11 +147,10 @@ fn mir_borrowck(tcx: TyCtxt<'_>, def: LocalDefId) -> &BorrowCheckResult<'_> {
155147/// If `return_body_with_facts` is true, then return the body with non-erased
156148/// region ids on which the borrow checking was performed together with Polonius
157149/// facts.
158- #[ instrument( skip( infcx, input_body, input_promoted ) , fields( id=?input_body. source. def_id( ) ) , level = "debug" ) ]
150+ #[ instrument( skip( infcx, input_body) , fields( id=?input_body. source. def_id( ) ) , level = "debug" ) ]
159151fn do_mir_borrowck < ' tcx > (
160152 infcx : & InferCtxt < ' tcx > ,
161153 input_body : & Body < ' tcx > ,
162- input_promoted : & IndexSlice < Promoted , Body < ' tcx > > ,
163154 return_body_with_facts : bool ,
164155) -> ( BorrowCheckResult < ' tcx > , Option < Box < BodyWithBorrowckFacts < ' tcx > > > ) {
165156 let def = input_body. source . def_id ( ) . expect_local ( ) ;
@@ -212,9 +203,7 @@ fn do_mir_borrowck<'tcx>(
212203 // be modified (in place) to contain non-lexical lifetimes. It
213204 // will have a lifetime tied to the inference context.
214205 let mut body_owned = input_body. clone ( ) ;
215- let mut promoted = input_promoted. to_owned ( ) ;
216- let free_regions =
217- nll:: replace_regions_in_mir ( & infcx, param_env, & mut body_owned, & mut promoted) ;
206+ let free_regions = nll:: replace_regions_in_mir ( & infcx, param_env, & mut body_owned) ;
218207 let body = & body_owned; // no further changes
219208
220209 let location_table_owned = LocationTable :: new ( body) ;
@@ -225,9 +214,6 @@ fn do_mir_borrowck<'tcx>(
225214 Ok ( ( _, move_data) ) => ( move_data, Vec :: new ( ) ) ,
226215 Err ( ( move_data, move_errors) ) => ( move_data, move_errors) ,
227216 } ;
228- let promoted_errors = promoted
229- . iter_enumerated ( )
230- . map ( |( idx, body) | ( idx, MoveData :: gather_moves ( & body, tcx, param_env) ) ) ;
231217
232218 let mdpe = MoveDataParamEnv { move_data, param_env } ;
233219
@@ -255,7 +241,6 @@ fn do_mir_borrowck<'tcx>(
255241 & infcx,
256242 free_regions,
257243 body,
258- & promoted,
259244 location_table,
260245 param_env,
261246 & mut flow_inits,
@@ -311,39 +296,6 @@ fn do_mir_borrowck<'tcx>(
311296 true
312297 } ;
313298
314- for ( idx, move_data_results) in promoted_errors {
315- let promoted_body = & promoted[ idx] ;
316-
317- if let Err ( ( move_data, move_errors) ) = move_data_results {
318- let mut promoted_mbcx = MirBorrowckCtxt {
319- infcx : & infcx,
320- param_env,
321- body : promoted_body,
322- move_data : & move_data,
323- location_table, // no need to create a real one for the promoted, it is not used
324- movable_generator,
325- fn_self_span_reported : Default :: default ( ) ,
326- locals_are_invalidated_at_exit,
327- access_place_error_reported : Default :: default ( ) ,
328- reservation_error_reported : Default :: default ( ) ,
329- uninitialized_error_reported : Default :: default ( ) ,
330- regioncx : regioncx. clone ( ) ,
331- used_mut : Default :: default ( ) ,
332- used_mut_upvars : SmallVec :: new ( ) ,
333- borrow_set : Rc :: clone ( & borrow_set) ,
334- dominators : Default :: default ( ) ,
335- upvars : Vec :: new ( ) ,
336- local_names : IndexVec :: from_elem ( None , & promoted_body. local_decls ) ,
337- region_names : RefCell :: default ( ) ,
338- next_region_name : RefCell :: new ( 1 ) ,
339- polonius_output : None ,
340- errors,
341- } ;
342- promoted_mbcx. report_move_errors ( move_errors) ;
343- errors = promoted_mbcx. errors ;
344- } ;
345- }
346-
347299 let mut mbcx = MirBorrowckCtxt {
348300 infcx : & infcx,
349301 param_env,
@@ -737,7 +689,6 @@ impl<'cx, 'tcx> rustc_mir_dataflow::ResultsVisitor<'cx, 'tcx> for MirBorrowckCtx
737689 }
738690 TerminatorKind :: Assert { cond, expected : _, msg, target : _, unwind : _ } => {
739691 self . consume_operand ( loc, ( cond, span) , flow_state) ;
740- use rustc_middle:: mir:: AssertKind ;
741692 if let AssertKind :: BoundsCheck { len, index } = & * * msg {
742693 self . consume_operand ( loc, ( len, span) , flow_state) ;
743694 self . consume_operand ( loc, ( index, span) , flow_state) ;
0 commit comments