@@ -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 , Origin } ;
25
+ use crate :: util:: borrowck_errors;
26
26
27
27
#[ derive( Debug ) ]
28
28
struct MoveSite {
@@ -89,12 +89,11 @@ 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 ) )
96
96
. unwrap_or_else ( || "_" . to_owned ( ) ) ,
97
- Origin :: Mir ,
98
97
) ;
99
98
err. span_label ( span, format ! ( "use of possibly uninitialized {}" , item_msg) ) ;
100
99
@@ -120,12 +119,11 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
120
119
121
120
let msg = "" ; //FIXME: add "partially " or "collaterally "
122
121
123
- let mut err = self . infcx . tcx . cannot_act_on_moved_value (
122
+ let mut err = self . cannot_act_on_moved_value (
124
123
span,
125
124
desired_action. as_noun ( ) ,
126
125
msg,
127
126
self . describe_place_with_options ( & moved_place, IncludingDowncast ( true ) ) ,
128
- Origin :: Mir ,
129
127
) ;
130
128
131
129
self . add_moved_or_invoked_closure_note (
@@ -267,7 +265,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
267
265
"report_move_out_while_borrowed: location={:?} place={:?} span={:?} borrow={:?}" ,
268
266
location, place, span, borrow
269
267
) ;
270
- let tcx = self . infcx . tcx ;
271
268
let value_msg = match self . describe_place ( place) {
272
269
Some ( name) => format ! ( "`{}`" , name) ,
273
270
None => "value" . to_owned ( ) ,
@@ -283,10 +280,9 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
283
280
let move_spans = self . move_spans ( place, location) ;
284
281
let span = move_spans. args_or_use ( ) ;
285
282
286
- let mut err = tcx . cannot_move_when_borrowed (
283
+ let mut err = self . cannot_move_when_borrowed (
287
284
span,
288
285
& self . describe_place ( place) . unwrap_or_else ( || "_" . to_owned ( ) ) ,
289
- Origin :: Mir ,
290
286
) ;
291
287
err. span_label ( borrow_span, format ! ( "borrow of {} occurs here" , borrow_msg) ) ;
292
288
err. span_label ( span, format ! ( "move out of {} occurs here" , value_msg) ) ;
@@ -315,8 +311,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
315
311
( place, _span) : ( & Place < ' tcx > , Span ) ,
316
312
borrow : & BorrowData < ' tcx > ,
317
313
) -> DiagnosticBuilder < ' cx > {
318
- let tcx = self . infcx . tcx ;
319
-
320
314
let borrow_spans = self . retrieve_borrow_spans ( borrow) ;
321
315
let borrow_span = borrow_spans. args_or_use ( ) ;
322
316
@@ -325,13 +319,12 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
325
319
let use_spans = self . move_spans ( place, location) ;
326
320
let span = use_spans. var_or_use ( ) ;
327
321
328
- let mut err = tcx . cannot_use_when_mutably_borrowed (
322
+ let mut err = self . cannot_use_when_mutably_borrowed (
329
323
span,
330
324
& self . describe_place ( place) . unwrap_or_else ( || "_" . to_owned ( ) ) ,
331
325
borrow_span,
332
326
& self . describe_place ( & borrow. borrowed_place )
333
327
. unwrap_or_else ( || "_" . to_owned ( ) ) ,
334
- Origin :: Mir ,
335
328
) ;
336
329
337
330
borrow_spans. var_span_label ( & mut err, {
@@ -376,7 +369,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
376
369
} ;
377
370
378
371
// FIXME: supply non-"" `opt_via` when appropriate
379
- let tcx = self . infcx . tcx ;
380
372
let first_borrow_desc;
381
373
let mut err = match (
382
374
gen_borrow_kind,
@@ -388,7 +380,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
388
380
) {
389
381
( BorrowKind :: Shared , lft, _, BorrowKind :: Mut { .. } , _, rgt) => {
390
382
first_borrow_desc = "mutable " ;
391
- tcx . cannot_reborrow_already_borrowed (
383
+ self . cannot_reborrow_already_borrowed (
392
384
span,
393
385
& desc_place,
394
386
& msg_place,
@@ -398,12 +390,11 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
398
390
rgt,
399
391
& msg_borrow,
400
392
None ,
401
- Origin :: Mir ,
402
393
)
403
394
}
404
395
( BorrowKind :: Mut { .. } , _, lft, BorrowKind :: Shared , rgt, _) => {
405
396
first_borrow_desc = "immutable " ;
406
- tcx . cannot_reborrow_already_borrowed (
397
+ self . cannot_reborrow_already_borrowed (
407
398
span,
408
399
& desc_place,
409
400
& msg_place,
@@ -413,42 +404,38 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
413
404
rgt,
414
405
& msg_borrow,
415
406
None ,
416
- Origin :: Mir ,
417
407
)
418
408
}
419
409
420
410
( BorrowKind :: Mut { .. } , _, _, BorrowKind :: Mut { .. } , _, _) => {
421
411
first_borrow_desc = "first " ;
422
- tcx . cannot_mutably_borrow_multiply (
412
+ self . cannot_mutably_borrow_multiply (
423
413
span,
424
414
& desc_place,
425
415
& msg_place,
426
416
issued_span,
427
417
& msg_borrow,
428
418
None ,
429
- Origin :: Mir ,
430
419
)
431
420
}
432
421
433
422
( BorrowKind :: Unique , _, _, BorrowKind :: Unique , _, _) => {
434
423
first_borrow_desc = "first " ;
435
- tcx . cannot_uniquely_borrow_by_two_closures (
424
+ self . cannot_uniquely_borrow_by_two_closures (
436
425
span,
437
426
& desc_place,
438
427
issued_span,
439
428
None ,
440
- Origin :: Mir ,
441
429
)
442
430
}
443
431
444
432
( BorrowKind :: Mut { .. } , _, _, BorrowKind :: Shallow , _, _)
445
433
| ( BorrowKind :: Unique , _, _, BorrowKind :: Shallow , _, _) => {
446
- let mut err = tcx . cannot_mutate_in_match_guard (
434
+ let mut err = self . cannot_mutate_in_match_guard (
447
435
span,
448
436
issued_span,
449
437
& desc_place,
450
438
"mutably borrow" ,
451
- Origin :: Mir ,
452
439
) ;
453
440
borrow_spans. var_span_label (
454
441
& mut err,
@@ -462,7 +449,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
462
449
463
450
( BorrowKind :: Unique , _, _, _, _, _) => {
464
451
first_borrow_desc = "first " ;
465
- tcx . cannot_uniquely_borrow_by_one_closure (
452
+ self . cannot_uniquely_borrow_by_one_closure (
466
453
span,
467
454
container_name,
468
455
& desc_place,
@@ -471,13 +458,12 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
471
458
"it" ,
472
459
"" ,
473
460
None ,
474
- Origin :: Mir ,
475
461
)
476
462
} ,
477
463
478
464
( BorrowKind :: Shared , lft, _, BorrowKind :: Unique , _, _) => {
479
465
first_borrow_desc = "first " ;
480
- tcx . cannot_reborrow_already_uniquely_borrowed (
466
+ self . cannot_reborrow_already_uniquely_borrowed (
481
467
span,
482
468
container_name,
483
469
& desc_place,
@@ -487,13 +473,12 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
487
473
"" ,
488
474
None ,
489
475
second_borrow_desc,
490
- Origin :: Mir ,
491
476
)
492
477
}
493
478
494
479
( BorrowKind :: Mut { .. } , _, lft, BorrowKind :: Unique , _, _) => {
495
480
first_borrow_desc = "first " ;
496
- tcx . cannot_reborrow_already_uniquely_borrowed (
481
+ self . cannot_reborrow_already_uniquely_borrowed (
497
482
span,
498
483
container_name,
499
484
& desc_place,
@@ -503,7 +488,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
503
488
"" ,
504
489
None ,
505
490
second_borrow_desc,
506
- Origin :: Mir ,
507
491
)
508
492
}
509
493
@@ -833,10 +817,9 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
833
817
}
834
818
}
835
819
836
- let mut err = self . infcx . tcx . path_does_not_live_long_enough (
820
+ let mut err = self . path_does_not_live_long_enough (
837
821
borrow_span,
838
822
& format ! ( "`{}`" , name) ,
839
- Origin :: Mir ,
840
823
) ;
841
824
842
825
if let Some ( annotation) = self . annotate_argument_and_return_for_borrow ( borrow) {
@@ -925,9 +908,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
925
908
let borrow_spans = self . retrieve_borrow_spans ( borrow) ;
926
909
let borrow_span = borrow_spans. var_or_use ( ) ;
927
910
928
- let mut err = self . infcx
929
- . tcx
930
- . cannot_borrow_across_destructor ( borrow_span, Origin :: Mir ) ;
911
+ let mut err = self . cannot_borrow_across_destructor ( borrow_span) ;
931
912
932
913
let what_was_dropped = match self . describe_place ( place) {
933
914
Some ( name) => format ! ( "`{}`" , name. as_str( ) ) ,
@@ -978,9 +959,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
978
959
drop_span, borrow_span
979
960
) ;
980
961
981
- let mut err = self . infcx
982
- . tcx
983
- . thread_local_value_does_not_live_long_enough ( borrow_span, Origin :: Mir ) ;
962
+ let mut err = self . thread_local_value_does_not_live_long_enough ( borrow_span) ;
984
963
985
964
err. span_label (
986
965
borrow_span,
@@ -1024,8 +1003,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1024
1003
}
1025
1004
}
1026
1005
1027
- let tcx = self . infcx . tcx ;
1028
- let mut err = tcx. temporary_value_borrowed_for_too_long ( proper_span, Origin :: Mir ) ;
1006
+ let mut err = self . temporary_value_borrowed_for_too_long ( proper_span) ;
1029
1007
err. span_label (
1030
1008
proper_span,
1031
1009
"creates a temporary which is freed while still in use" ,
@@ -1068,8 +1046,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1068
1046
category : ConstraintCategory ,
1069
1047
opt_place_desc : Option < & String > ,
1070
1048
) -> Option < DiagnosticBuilder < ' cx > > {
1071
- let tcx = self . infcx . tcx ;
1072
-
1073
1049
let return_kind = match category {
1074
1050
ConstraintCategory :: Return => "return" ,
1075
1051
ConstraintCategory :: Yield => "yield" ,
@@ -1132,12 +1108,11 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1132
1108
}
1133
1109
} ;
1134
1110
1135
- let mut err = tcx . cannot_return_reference_to_local (
1111
+ let mut err = self . cannot_return_reference_to_local (
1136
1112
return_span,
1137
1113
return_kind,
1138
1114
reference_desc,
1139
1115
& place_desc,
1140
- Origin :: Mir ,
1141
1116
) ;
1142
1117
1143
1118
if return_span != borrow_span {
@@ -1158,11 +1133,10 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1158
1133
) -> DiagnosticBuilder < ' cx > {
1159
1134
let tcx = self . infcx . tcx ;
1160
1135
1161
- let mut err = tcx . cannot_capture_in_long_lived_closure (
1136
+ let mut err = self . cannot_capture_in_long_lived_closure (
1162
1137
args_span,
1163
1138
captured_var,
1164
1139
var_span,
1165
- Origin :: Mir ,
1166
1140
) ;
1167
1141
1168
1142
let suggestion = match tcx. sess . source_map ( ) . span_to_snippet ( args_span) {
@@ -1218,7 +1192,11 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1218
1192
"function"
1219
1193
} ;
1220
1194
1221
- let mut err = tcx. borrowed_data_escapes_closure ( escape_span, escapes_from, Origin :: Mir ) ;
1195
+ let mut err = borrowck_errors:: borrowed_data_escapes_closure (
1196
+ tcx,
1197
+ escape_span,
1198
+ escapes_from,
1199
+ ) ;
1222
1200
1223
1201
err. span_label (
1224
1202
upvar_span,
@@ -1360,14 +1338,12 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1360
1338
let loan_spans = self . retrieve_borrow_spans ( loan) ;
1361
1339
let loan_span = loan_spans. args_or_use ( ) ;
1362
1340
1363
- let tcx = self . infcx . tcx ;
1364
1341
if loan. kind == BorrowKind :: Shallow {
1365
- let mut err = tcx . cannot_mutate_in_match_guard (
1342
+ let mut err = self . cannot_mutate_in_match_guard (
1366
1343
span,
1367
1344
loan_span,
1368
1345
& self . describe_place ( place) . unwrap_or_else ( || "_" . to_owned ( ) ) ,
1369
1346
"assign" ,
1370
- Origin :: Mir ,
1371
1347
) ;
1372
1348
loan_spans. var_span_label (
1373
1349
& mut err,
@@ -1379,11 +1355,10 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1379
1355
return ;
1380
1356
}
1381
1357
1382
- let mut err = tcx . cannot_assign_to_borrowed (
1358
+ let mut err = self . cannot_assign_to_borrowed (
1383
1359
span,
1384
1360
loan_span,
1385
1361
& self . describe_place ( place) . unwrap_or_else ( || "_" . to_owned ( ) ) ,
1386
- Origin :: Mir ,
1387
1362
) ;
1388
1363
1389
1364
loan_spans. var_span_label (
@@ -1444,11 +1419,10 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1444
1419
Some ( decl) => ( self . describe_place ( err_place) , decl. source_info . span ) ,
1445
1420
} ;
1446
1421
1447
- let mut err = self . infcx . tcx . cannot_reassign_immutable (
1422
+ let mut err = self . cannot_reassign_immutable (
1448
1423
span,
1449
1424
place_description. as_ref ( ) . map ( AsRef :: as_ref) . unwrap_or ( "_" ) ,
1450
1425
from_arg,
1451
- Origin :: Mir ,
1452
1426
) ;
1453
1427
let msg = if from_arg {
1454
1428
"cannot assign to immutable argument"
0 commit comments