@@ -24,17 +24,11 @@ use rustc_fluent_macro::fluent_messages;
24
24
use rustc_hir as hir;
25
25
use rustc_hir:: def_id:: LocalDefId ;
26
26
use rustc_index:: bit_set:: ChunkedBitSet ;
27
- use rustc_index:: { IndexSlice , IndexVec } ;
27
+ use rustc_index:: IndexVec ;
28
28
use rustc_infer:: infer:: {
29
29
DefiningAnchor , InferCtxt , NllRegionVariableOrigin , RegionVariableOrigin , TyCtxtInferExt ,
30
30
} ;
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:: * ;
38
32
use rustc_middle:: query:: Providers ;
39
33
use rustc_middle:: ty:: { self , CapturedPlace , ParamEnv , RegionVid , TyCtxt } ;
40
34
use rustc_session:: lint:: builtin:: UNUSED_MUT ;
@@ -123,7 +117,7 @@ pub fn provide(providers: &mut Providers) {
123
117
}
124
118
125
119
fn mir_borrowck ( tcx : TyCtxt < ' _ > , def : LocalDefId ) -> & BorrowCheckResult < ' _ > {
126
- let ( input_body, promoted ) = tcx. mir_promoted ( def) ;
120
+ let ( input_body, _ ) = tcx. mir_promoted ( def) ;
127
121
debug ! ( "run query mir_borrowck: {}" , tcx. def_path_str( def) ) ;
128
122
129
123
if input_body. borrow ( ) . should_skip ( ) {
@@ -138,13 +132,11 @@ fn mir_borrowck(tcx: TyCtxt<'_>, def: LocalDefId) -> &BorrowCheckResult<'_> {
138
132
return tcx. arena . alloc ( result) ;
139
133
}
140
134
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 ( ) ;
143
136
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 ( ) ;
145
138
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 ;
148
140
debug ! ( "mir_borrowck done" ) ;
149
141
150
142
tcx. arena . alloc ( opt_closure_req)
@@ -155,11 +147,10 @@ fn mir_borrowck(tcx: TyCtxt<'_>, def: LocalDefId) -> &BorrowCheckResult<'_> {
155
147
/// If `return_body_with_facts` is true, then return the body with non-erased
156
148
/// region ids on which the borrow checking was performed together with Polonius
157
149
/// 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" ) ]
159
151
fn do_mir_borrowck < ' tcx > (
160
152
infcx : & InferCtxt < ' tcx > ,
161
153
input_body : & Body < ' tcx > ,
162
- input_promoted : & IndexSlice < Promoted , Body < ' tcx > > ,
163
154
return_body_with_facts : bool ,
164
155
) -> ( BorrowCheckResult < ' tcx > , Option < Box < BodyWithBorrowckFacts < ' tcx > > > ) {
165
156
let def = input_body. source . def_id ( ) . expect_local ( ) ;
@@ -212,9 +203,7 @@ fn do_mir_borrowck<'tcx>(
212
203
// be modified (in place) to contain non-lexical lifetimes. It
213
204
// will have a lifetime tied to the inference context.
214
205
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) ;
218
207
let body = & body_owned; // no further changes
219
208
220
209
let location_table_owned = LocationTable :: new ( body) ;
@@ -225,9 +214,6 @@ fn do_mir_borrowck<'tcx>(
225
214
Ok ( ( _, move_data) ) => ( move_data, Vec :: new ( ) ) ,
226
215
Err ( ( move_data, move_errors) ) => ( move_data, move_errors) ,
227
216
} ;
228
- let promoted_errors = promoted
229
- . iter_enumerated ( )
230
- . map ( |( idx, body) | ( idx, MoveData :: gather_moves ( & body, tcx, param_env) ) ) ;
231
217
232
218
let mdpe = MoveDataParamEnv { move_data, param_env } ;
233
219
@@ -255,7 +241,6 @@ fn do_mir_borrowck<'tcx>(
255
241
& infcx,
256
242
free_regions,
257
243
body,
258
- & promoted,
259
244
location_table,
260
245
param_env,
261
246
& mut flow_inits,
@@ -311,39 +296,6 @@ fn do_mir_borrowck<'tcx>(
311
296
true
312
297
} ;
313
298
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
-
347
299
let mut mbcx = MirBorrowckCtxt {
348
300
infcx : & infcx,
349
301
param_env,
@@ -737,7 +689,6 @@ impl<'cx, 'tcx> rustc_mir_dataflow::ResultsVisitor<'cx, 'tcx> for MirBorrowckCtx
737
689
}
738
690
TerminatorKind :: Assert { cond, expected : _, msg, target : _, unwind : _ } => {
739
691
self . consume_operand ( loc, ( cond, span) , flow_state) ;
740
- use rustc_middle:: mir:: AssertKind ;
741
692
if let AssertKind :: BoundsCheck { len, index } = & * * msg {
742
693
self . consume_operand ( loc, ( len, span) , flow_state) ;
743
694
self . consume_operand ( loc, ( index, span) , flow_state) ;
0 commit comments