@@ -22,7 +22,7 @@ use syntax_pos::Span;
22
22
use syntax:: source_map:: CompilerDesugaringKind ;
23
23
24
24
use super :: borrow_set:: BorrowData ;
25
- use super :: { Context , MirBorrowckCtxt } ;
25
+ use super :: { MirBorrowckCtxt } ;
26
26
use super :: { InitializationRequiringAction , PrefixSet } ;
27
27
use crate :: dataflow:: drop_flag_effects;
28
28
use crate :: dataflow:: indexes:: { MovePathIndex , MoveOutIndex } ;
@@ -42,22 +42,22 @@ struct MoveSite {
42
42
impl < ' cx , ' gcx , ' tcx > MirBorrowckCtxt < ' cx , ' gcx , ' tcx > {
43
43
pub ( super ) fn report_use_of_moved_or_uninitialized (
44
44
& mut self ,
45
- context : Context ,
45
+ location : Location ,
46
46
desired_action : InitializationRequiringAction ,
47
47
( moved_place, used_place, span) : ( & Place < ' tcx > , & Place < ' tcx > , Span ) ,
48
48
mpi : MovePathIndex ,
49
49
) {
50
50
debug ! (
51
- "report_use_of_moved_or_uninitialized: context ={:?} desired_action={:?} \
51
+ "report_use_of_moved_or_uninitialized: location ={:?} desired_action={:?} \
52
52
moved_place={:?} used_place={:?} span={:?} mpi={:?}",
53
- context , desired_action, moved_place, used_place, span, mpi
53
+ location , desired_action, moved_place, used_place, span, mpi
54
54
) ;
55
55
56
- let use_spans = self . move_spans ( moved_place, context . loc )
57
- . or_else ( || self . borrow_spans ( span, context . loc ) ) ;
56
+ let use_spans = self . move_spans ( moved_place, location )
57
+ . or_else ( || self . borrow_spans ( span, location ) ) ;
58
58
let span = use_spans. args_or_use ( ) ;
59
59
60
- let move_site_vec = self . get_moved_indexes ( context , mpi) ;
60
+ let move_site_vec = self . get_moved_indexes ( location , mpi) ;
61
61
debug ! (
62
62
"report_use_of_moved_or_uninitialized: move_site_vec={:?}" ,
63
63
move_site_vec
@@ -125,7 +125,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
125
125
) ;
126
126
127
127
self . add_moved_or_invoked_closure_note (
128
- context . loc ,
128
+ location ,
129
129
used_place,
130
130
& mut err,
131
131
) ;
@@ -261,13 +261,13 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
261
261
262
262
pub ( super ) fn report_move_out_while_borrowed (
263
263
& mut self ,
264
- context : Context ,
264
+ location : Location ,
265
265
( place, span) : ( & Place < ' tcx > , Span ) ,
266
266
borrow : & BorrowData < ' tcx > ,
267
267
) {
268
268
debug ! (
269
- "report_move_out_while_borrowed: context ={:?} place={:?} span={:?} borrow={:?}" ,
270
- context , place, span, borrow
269
+ "report_move_out_while_borrowed: location ={:?} place={:?} span={:?} borrow={:?}" ,
270
+ location , place, span, borrow
271
271
) ;
272
272
let tcx = self . infcx . tcx ;
273
273
let value_msg = match self . describe_place ( place) {
@@ -282,7 +282,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
282
282
let borrow_spans = self . retrieve_borrow_spans ( borrow) ;
283
283
let borrow_span = borrow_spans. args_or_use ( ) ;
284
284
285
- let move_spans = self . move_spans ( place, context . loc ) ;
285
+ let move_spans = self . move_spans ( place, location ) ;
286
286
let span = move_spans. args_or_use ( ) ;
287
287
288
288
let mut err = tcx. cannot_move_when_borrowed (
@@ -304,7 +304,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
304
304
) ;
305
305
306
306
self . explain_why_borrow_contains_point (
307
- context ,
307
+ location ,
308
308
borrow,
309
309
None ,
310
310
) . add_explanation_to_diagnostic ( self . infcx . tcx , self . mir , & mut err, "" , Some ( borrow_span) ) ;
@@ -313,7 +313,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
313
313
314
314
pub ( super ) fn report_use_while_mutably_borrowed (
315
315
& mut self ,
316
- context : Context ,
316
+ location : Location ,
317
317
( place, _span) : ( & Place < ' tcx > , Span ) ,
318
318
borrow : & BorrowData < ' tcx > ,
319
319
) -> DiagnosticBuilder < ' cx > {
@@ -324,7 +324,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
324
324
325
325
// Conflicting borrows are reported separately, so only check for move
326
326
// captures.
327
- let use_spans = self . move_spans ( place, context . loc ) ;
327
+ let use_spans = self . move_spans ( place, location ) ;
328
328
let span = use_spans. var_or_use ( ) ;
329
329
330
330
let mut err = tcx. cannot_use_when_mutably_borrowed (
@@ -343,22 +343,22 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
343
343
format ! ( "borrow occurs due to use of `{}`{}" , desc_place, borrow_spans. describe( ) )
344
344
} ) ;
345
345
346
- self . explain_why_borrow_contains_point ( context , borrow, None )
346
+ self . explain_why_borrow_contains_point ( location , borrow, None )
347
347
. add_explanation_to_diagnostic ( self . infcx . tcx , self . mir , & mut err, "" , None ) ;
348
348
err
349
349
}
350
350
351
351
pub ( super ) fn report_conflicting_borrow (
352
352
& mut self ,
353
- context : Context ,
353
+ location : Location ,
354
354
( place, span) : ( & Place < ' tcx > , Span ) ,
355
355
gen_borrow_kind : BorrowKind ,
356
356
issued_borrow : & BorrowData < ' tcx > ,
357
357
) -> DiagnosticBuilder < ' cx > {
358
358
let issued_spans = self . retrieve_borrow_spans ( issued_borrow) ;
359
359
let issued_span = issued_spans. args_or_use ( ) ;
360
360
361
- let borrow_spans = self . borrow_spans ( span, context . loc ) ;
361
+ let borrow_spans = self . borrow_spans ( span, location ) ;
362
362
let span = borrow_spans. args_or_use ( ) ;
363
363
364
364
let container_name = if issued_spans. for_generator ( ) || borrow_spans. for_generator ( ) {
@@ -370,7 +370,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
370
370
let ( desc_place, msg_place, msg_borrow, union_type_name) =
371
371
self . describe_place_for_conflicting_borrow ( place, & issued_borrow. borrowed_place ) ;
372
372
373
- let explanation = self . explain_why_borrow_contains_point ( context , issued_borrow, None ) ;
373
+ let explanation = self . explain_why_borrow_contains_point ( location , issued_borrow, None ) ;
374
374
let second_borrow_desc = if explanation. is_explained ( ) {
375
375
"second "
376
376
} else {
@@ -671,7 +671,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
671
671
/// `Drop::drop` with an aliasing borrow.)
672
672
pub ( super ) fn report_borrowed_value_does_not_live_long_enough (
673
673
& mut self ,
674
- context : Context ,
674
+ location : Location ,
675
675
borrow : & BorrowData < ' tcx > ,
676
676
place_span : ( & Place < ' tcx > , Span ) ,
677
677
kind : Option < WriteKind > ,
@@ -680,7 +680,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
680
680
"report_borrowed_value_does_not_live_long_enough(\
681
681
{:?}, {:?}, {:?}, {:?}\
682
682
)",
683
- context , borrow, place_span, kind
683
+ location , borrow, place_span, kind
684
684
) ;
685
685
686
686
let drop_span = place_span. 1 ;
@@ -719,7 +719,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
719
719
// destructor conflict.
720
720
if !borrow. borrowed_place . is_prefix_of ( place_span. 0 ) {
721
721
self . report_borrow_conflicts_with_destructor (
722
- context , borrow, place_span, kind, dropped_ty,
722
+ location , borrow, place_span, kind, dropped_ty,
723
723
) ;
724
724
return ;
725
725
}
@@ -728,7 +728,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
728
728
let place_desc = self . describe_place ( & borrow. borrowed_place ) ;
729
729
730
730
let kind_place = kind. filter ( |_| place_desc. is_some ( ) ) . map ( |k| ( k, place_span. 0 ) ) ;
731
- let explanation = self . explain_why_borrow_contains_point ( context , & borrow, kind_place) ;
731
+ let explanation = self . explain_why_borrow_contains_point ( location , & borrow, kind_place) ;
732
732
733
733
let err = match ( place_desc, explanation) {
734
734
( Some ( _) , _) if self . is_place_thread_local ( root_place) => {
@@ -784,7 +784,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
784
784
} ,
785
785
) => self . report_escaping_data ( borrow_span, name, upvar_span, upvar_name, span) ,
786
786
( Some ( name) , explanation) => self . report_local_value_does_not_live_long_enough (
787
- context ,
787
+ location ,
788
788
& name,
789
789
& scope_tree,
790
790
& borrow,
@@ -793,7 +793,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
793
793
explanation,
794
794
) ,
795
795
( None , explanation) => self . report_temporary_value_does_not_live_long_enough (
796
- context ,
796
+ location ,
797
797
& scope_tree,
798
798
& borrow,
799
799
drop_span,
@@ -808,7 +808,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
808
808
809
809
fn report_local_value_does_not_live_long_enough (
810
810
& mut self ,
811
- context : Context ,
811
+ location : Location ,
812
812
name : & str ,
813
813
scope_tree : & ' tcx ScopeTree ,
814
814
borrow : & BorrowData < ' tcx > ,
@@ -820,7 +820,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
820
820
"report_local_value_does_not_live_long_enough(\
821
821
{:?}, {:?}, {:?}, {:?}, {:?}, {:?}\
822
822
)",
823
- context , name, scope_tree, borrow, drop_span, borrow_spans
823
+ location , name, scope_tree, borrow, drop_span, borrow_spans
824
824
) ;
825
825
826
826
let borrow_span = borrow_spans. var_or_use ( ) ;
@@ -914,7 +914,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
914
914
915
915
fn report_borrow_conflicts_with_destructor (
916
916
& mut self ,
917
- context : Context ,
917
+ location : Location ,
918
918
borrow : & BorrowData < ' tcx > ,
919
919
( place, drop_span) : ( & Place < ' tcx > , Span ) ,
920
920
kind : Option < WriteKind > ,
@@ -924,7 +924,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
924
924
"report_borrow_conflicts_with_destructor(\
925
925
{:?}, {:?}, ({:?}, {:?}), {:?}\
926
926
)",
927
- context , borrow, place, drop_span, kind,
927
+ location , borrow, place, drop_span, kind,
928
928
) ;
929
929
930
930
let borrow_spans = self . retrieve_borrow_spans ( borrow) ;
@@ -957,7 +957,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
957
957
958
958
// Only give this note and suggestion if they could be relevant.
959
959
let explanation =
960
- self . explain_why_borrow_contains_point ( context , borrow, kind. map ( |k| ( k, place) ) ) ;
960
+ self . explain_why_borrow_contains_point ( location , borrow, kind. map ( |k| ( k, place) ) ) ;
961
961
match explanation {
962
962
BorrowExplanation :: UsedLater { .. }
963
963
| BorrowExplanation :: UsedLaterWhenDropped { .. } => {
@@ -998,7 +998,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
998
998
999
999
fn report_temporary_value_does_not_live_long_enough (
1000
1000
& mut self ,
1001
- context : Context ,
1001
+ location : Location ,
1002
1002
scope_tree : & ' tcx ScopeTree ,
1003
1003
borrow : & BorrowData < ' tcx > ,
1004
1004
drop_span : Span ,
@@ -1010,7 +1010,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
1010
1010
"report_temporary_value_does_not_live_long_enough(\
1011
1011
{:?}, {:?}, {:?}, {:?}, {:?}\
1012
1012
)",
1013
- context , scope_tree, borrow, drop_span, proper_span
1013
+ location , scope_tree, borrow, drop_span, proper_span
1014
1014
) ;
1015
1015
1016
1016
if let BorrowExplanation :: MustBeValidFor {
@@ -1246,12 +1246,12 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
1246
1246
err
1247
1247
}
1248
1248
1249
- fn get_moved_indexes ( & mut self , context : Context , mpi : MovePathIndex ) -> Vec < MoveSite > {
1249
+ fn get_moved_indexes ( & mut self , location : Location , mpi : MovePathIndex ) -> Vec < MoveSite > {
1250
1250
let mir = self . mir ;
1251
1251
1252
1252
let mut stack = Vec :: new ( ) ;
1253
- stack. extend ( mir. predecessor_locations ( context . loc ) . map ( |predecessor| {
1254
- let is_back_edge = context . loc . dominates ( predecessor, & self . dominators ) ;
1253
+ stack. extend ( mir. predecessor_locations ( location ) . map ( |predecessor| {
1254
+ let is_back_edge = location . dominates ( predecessor, & self . dominators ) ;
1255
1255
( predecessor, is_back_edge)
1256
1256
} ) ) ;
1257
1257
@@ -1348,7 +1348,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
1348
1348
1349
1349
pub ( super ) fn report_illegal_mutation_of_borrowed (
1350
1350
& mut self ,
1351
- context : Context ,
1351
+ location : Location ,
1352
1352
( place, span) : ( & Place < ' tcx > , Span ) ,
1353
1353
loan : & BorrowData < ' tcx > ,
1354
1354
) {
@@ -1386,7 +1386,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
1386
1386
format ! ( "borrow occurs due to use{}" , loan_spans. describe( ) ) ,
1387
1387
) ;
1388
1388
1389
- self . explain_why_borrow_contains_point ( context , loan, None )
1389
+ self . explain_why_borrow_contains_point ( location , loan, None )
1390
1390
. add_explanation_to_diagnostic ( self . infcx . tcx , self . mir , & mut err, "" , None ) ;
1391
1391
1392
1392
err. buffer ( & mut self . errors_buffer ) ;
@@ -1400,7 +1400,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
1400
1400
/// assignment to `x.f`).
1401
1401
pub ( super ) fn report_illegal_reassignment (
1402
1402
& mut self ,
1403
- _context : Context ,
1403
+ _location : Location ,
1404
1404
( place, span) : ( & Place < ' tcx > , Span ) ,
1405
1405
assigned_span : Span ,
1406
1406
err_place : & Place < ' tcx > ,
0 commit comments