@@ -22,7 +22,7 @@ use super::{InitializationRequiringAction, PrefixSet};
22
22
use super :: error_reporting:: { IncludingDowncast , UseSpans } ;
23
23
use crate :: dataflow:: drop_flag_effects;
24
24
use crate :: dataflow:: indexes:: { MovePathIndex , MoveOutIndex } ;
25
- use crate :: util:: borrowck_errors:: BorrowckErrors ;
25
+ use crate :: util:: borrowck_errors;
26
26
27
27
#[ derive( Debug ) ]
28
28
struct MoveSite {
@@ -89,7 +89,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
89
89
Some ( name) => format ! ( "`{}`" , name) ,
90
90
None => "value" . to_owned ( ) ,
91
91
} ;
92
- let mut err = self . infcx . tcx . cannot_act_on_uninitialized_variable (
92
+ let mut err = self . cannot_act_on_uninitialized_variable (
93
93
span,
94
94
desired_action. as_noun ( ) ,
95
95
& self . describe_place_with_options ( moved_place, IncludingDowncast ( true ) )
@@ -119,7 +119,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
119
119
120
120
let msg = "" ; //FIXME: add "partially " or "collaterally "
121
121
122
- let mut err = self . infcx . tcx . cannot_act_on_moved_value (
122
+ let mut err = self . cannot_act_on_moved_value (
123
123
span,
124
124
desired_action. as_noun ( ) ,
125
125
msg,
@@ -265,7 +265,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
265
265
"report_move_out_while_borrowed: location={:?} place={:?} span={:?} borrow={:?}" ,
266
266
location, place, span, borrow
267
267
) ;
268
- let tcx = self . infcx . tcx ;
269
268
let value_msg = match self . describe_place ( place) {
270
269
Some ( name) => format ! ( "`{}`" , name) ,
271
270
None => "value" . to_owned ( ) ,
@@ -281,7 +280,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
281
280
let move_spans = self . move_spans ( place, location) ;
282
281
let span = move_spans. args_or_use ( ) ;
283
282
284
- let mut err = tcx . cannot_move_when_borrowed (
283
+ let mut err = self . cannot_move_when_borrowed (
285
284
span,
286
285
& self . describe_place ( place) . unwrap_or_else ( || "_" . to_owned ( ) ) ,
287
286
) ;
@@ -312,8 +311,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
312
311
( place, _span) : ( & Place < ' tcx > , Span ) ,
313
312
borrow : & BorrowData < ' tcx > ,
314
313
) -> DiagnosticBuilder < ' cx > {
315
- let tcx = self . infcx . tcx ;
316
-
317
314
let borrow_spans = self . retrieve_borrow_spans ( borrow) ;
318
315
let borrow_span = borrow_spans. args_or_use ( ) ;
319
316
@@ -322,7 +319,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
322
319
let use_spans = self . move_spans ( place, location) ;
323
320
let span = use_spans. var_or_use ( ) ;
324
321
325
- let mut err = tcx . cannot_use_when_mutably_borrowed (
322
+ let mut err = self . cannot_use_when_mutably_borrowed (
326
323
span,
327
324
& self . describe_place ( place) . unwrap_or_else ( || "_" . to_owned ( ) ) ,
328
325
borrow_span,
@@ -372,7 +369,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
372
369
} ;
373
370
374
371
// FIXME: supply non-"" `opt_via` when appropriate
375
- let tcx = self . infcx . tcx ;
376
372
let first_borrow_desc;
377
373
let mut err = match (
378
374
gen_borrow_kind,
@@ -384,7 +380,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
384
380
) {
385
381
( BorrowKind :: Shared , lft, _, BorrowKind :: Mut { .. } , _, rgt) => {
386
382
first_borrow_desc = "mutable " ;
387
- tcx . cannot_reborrow_already_borrowed (
383
+ self . cannot_reborrow_already_borrowed (
388
384
span,
389
385
& desc_place,
390
386
& msg_place,
@@ -398,7 +394,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
398
394
}
399
395
( BorrowKind :: Mut { .. } , _, lft, BorrowKind :: Shared , rgt, _) => {
400
396
first_borrow_desc = "immutable " ;
401
- tcx . cannot_reborrow_already_borrowed (
397
+ self . cannot_reborrow_already_borrowed (
402
398
span,
403
399
& desc_place,
404
400
& msg_place,
@@ -413,7 +409,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
413
409
414
410
( BorrowKind :: Mut { .. } , _, _, BorrowKind :: Mut { .. } , _, _) => {
415
411
first_borrow_desc = "first " ;
416
- tcx . cannot_mutably_borrow_multiply (
412
+ self . cannot_mutably_borrow_multiply (
417
413
span,
418
414
& desc_place,
419
415
& msg_place,
@@ -425,7 +421,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
425
421
426
422
( BorrowKind :: Unique , _, _, BorrowKind :: Unique , _, _) => {
427
423
first_borrow_desc = "first " ;
428
- tcx . cannot_uniquely_borrow_by_two_closures (
424
+ self . cannot_uniquely_borrow_by_two_closures (
429
425
span,
430
426
& desc_place,
431
427
issued_span,
@@ -435,7 +431,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
435
431
436
432
( BorrowKind :: Mut { .. } , _, _, BorrowKind :: Shallow , _, _)
437
433
| ( BorrowKind :: Unique , _, _, BorrowKind :: Shallow , _, _) => {
438
- let mut err = tcx . cannot_mutate_in_match_guard (
434
+ let mut err = self . cannot_mutate_in_match_guard (
439
435
span,
440
436
issued_span,
441
437
& desc_place,
@@ -453,7 +449,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
453
449
454
450
( BorrowKind :: Unique , _, _, _, _, _) => {
455
451
first_borrow_desc = "first " ;
456
- tcx . cannot_uniquely_borrow_by_one_closure (
452
+ self . cannot_uniquely_borrow_by_one_closure (
457
453
span,
458
454
container_name,
459
455
& desc_place,
@@ -467,7 +463,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
467
463
468
464
( BorrowKind :: Shared , lft, _, BorrowKind :: Unique , _, _) => {
469
465
first_borrow_desc = "first " ;
470
- tcx . cannot_reborrow_already_uniquely_borrowed (
466
+ self . cannot_reborrow_already_uniquely_borrowed (
471
467
span,
472
468
container_name,
473
469
& desc_place,
@@ -482,7 +478,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
482
478
483
479
( BorrowKind :: Mut { .. } , _, lft, BorrowKind :: Unique , _, _) => {
484
480
first_borrow_desc = "first " ;
485
- tcx . cannot_reborrow_already_uniquely_borrowed (
481
+ self . cannot_reborrow_already_uniquely_borrowed (
486
482
span,
487
483
container_name,
488
484
& desc_place,
@@ -821,7 +817,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
821
817
}
822
818
}
823
819
824
- let mut err = self . infcx . tcx . path_does_not_live_long_enough (
820
+ let mut err = self . path_does_not_live_long_enough (
825
821
borrow_span,
826
822
& format ! ( "`{}`" , name) ,
827
823
) ;
@@ -912,9 +908,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
912
908
let borrow_spans = self . retrieve_borrow_spans ( borrow) ;
913
909
let borrow_span = borrow_spans. var_or_use ( ) ;
914
910
915
- let mut err = self . infcx
916
- . tcx
917
- . cannot_borrow_across_destructor ( borrow_span) ;
911
+ let mut err = self . cannot_borrow_across_destructor ( borrow_span) ;
918
912
919
913
let what_was_dropped = match self . describe_place ( place) {
920
914
Some ( name) => format ! ( "`{}`" , name. as_str( ) ) ,
@@ -965,9 +959,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
965
959
drop_span, borrow_span
966
960
) ;
967
961
968
- let mut err = self . infcx
969
- . tcx
970
- . thread_local_value_does_not_live_long_enough ( borrow_span) ;
962
+ let mut err = self . thread_local_value_does_not_live_long_enough ( borrow_span) ;
971
963
972
964
err. span_label (
973
965
borrow_span,
@@ -1011,8 +1003,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1011
1003
}
1012
1004
}
1013
1005
1014
- let tcx = self . infcx . tcx ;
1015
- let mut err = tcx. temporary_value_borrowed_for_too_long ( proper_span) ;
1006
+ let mut err = self . temporary_value_borrowed_for_too_long ( proper_span) ;
1016
1007
err. span_label (
1017
1008
proper_span,
1018
1009
"creates a temporary which is freed while still in use" ,
@@ -1055,8 +1046,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1055
1046
category : ConstraintCategory ,
1056
1047
opt_place_desc : Option < & String > ,
1057
1048
) -> Option < DiagnosticBuilder < ' cx > > {
1058
- let tcx = self . infcx . tcx ;
1059
-
1060
1049
let return_kind = match category {
1061
1050
ConstraintCategory :: Return => "return" ,
1062
1051
ConstraintCategory :: Yield => "yield" ,
@@ -1119,7 +1108,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1119
1108
}
1120
1109
} ;
1121
1110
1122
- let mut err = tcx . cannot_return_reference_to_local (
1111
+ let mut err = self . cannot_return_reference_to_local (
1123
1112
return_span,
1124
1113
return_kind,
1125
1114
reference_desc,
@@ -1144,7 +1133,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1144
1133
) -> DiagnosticBuilder < ' cx > {
1145
1134
let tcx = self . infcx . tcx ;
1146
1135
1147
- let mut err = tcx . cannot_capture_in_long_lived_closure (
1136
+ let mut err = self . cannot_capture_in_long_lived_closure (
1148
1137
args_span,
1149
1138
captured_var,
1150
1139
var_span,
@@ -1203,7 +1192,11 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1203
1192
"function"
1204
1193
} ;
1205
1194
1206
- let mut err = tcx. borrowed_data_escapes_closure ( escape_span, escapes_from) ;
1195
+ let mut err = borrowck_errors:: borrowed_data_escapes_closure (
1196
+ tcx,
1197
+ escape_span,
1198
+ escapes_from,
1199
+ ) ;
1207
1200
1208
1201
err. span_label (
1209
1202
upvar_span,
@@ -1345,9 +1338,8 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1345
1338
let loan_spans = self . retrieve_borrow_spans ( loan) ;
1346
1339
let loan_span = loan_spans. args_or_use ( ) ;
1347
1340
1348
- let tcx = self . infcx . tcx ;
1349
1341
if loan. kind == BorrowKind :: Shallow {
1350
- let mut err = tcx . cannot_mutate_in_match_guard (
1342
+ let mut err = self . cannot_mutate_in_match_guard (
1351
1343
span,
1352
1344
loan_span,
1353
1345
& self . describe_place ( place) . unwrap_or_else ( || "_" . to_owned ( ) ) ,
@@ -1363,7 +1355,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1363
1355
return ;
1364
1356
}
1365
1357
1366
- let mut err = tcx . cannot_assign_to_borrowed (
1358
+ let mut err = self . cannot_assign_to_borrowed (
1367
1359
span,
1368
1360
loan_span,
1369
1361
& self . describe_place ( place) . unwrap_or_else ( || "_" . to_owned ( ) ) ,
@@ -1427,7 +1419,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1427
1419
Some ( decl) => ( self . describe_place ( err_place) , decl. source_info . span ) ,
1428
1420
} ;
1429
1421
1430
- let mut err = self . infcx . tcx . cannot_reassign_immutable (
1422
+ let mut err = self . cannot_reassign_immutable (
1431
1423
span,
1432
1424
place_description. as_ref ( ) . map ( AsRef :: as_ref) . unwrap_or ( "_" ) ,
1433
1425
from_arg,
0 commit comments