@@ -124,6 +124,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
124
124
( place, span) : ( & Place < ' tcx > , Span ) ,
125
125
borrow : & BorrowData < ' tcx > ,
126
126
) {
127
+ let tcx = self . tcx ;
127
128
let value_msg = match self . describe_place ( place) {
128
129
Some ( name) => format ! ( "`{}`" , name) ,
129
130
None => "value" . to_owned ( ) ,
@@ -132,7 +133,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
132
133
Some ( name) => format ! ( "`{}`" , name) ,
133
134
None => "value" . to_owned ( ) ,
134
135
} ;
135
- let mut err = self . tcx . cannot_move_when_borrowed (
136
+ let mut err = tcx. cannot_move_when_borrowed (
136
137
span,
137
138
& self . describe_place ( place) . unwrap_or ( "_" . to_owned ( ) ) ,
138
139
Origin :: Mir ,
@@ -152,7 +153,8 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
152
153
( place, span) : ( & Place < ' tcx > , Span ) ,
153
154
borrow : & BorrowData < ' tcx > ,
154
155
) {
155
- let mut err = self . tcx . cannot_use_when_mutably_borrowed (
156
+ let tcx = self . tcx ;
157
+ let mut err = tcx. cannot_use_when_mutably_borrowed (
156
158
span,
157
159
& self . describe_place ( place) . unwrap_or ( "_" . to_owned ( ) ) ,
158
160
self . retrieve_borrow_span ( borrow) ,
@@ -254,6 +256,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
254
256
. unwrap_or ( issued_span) ;
255
257
256
258
let desc_place = self . describe_place ( place) . unwrap_or ( "_" . to_owned ( ) ) ;
259
+ let tcx = self . tcx ;
257
260
258
261
// FIXME: supply non-"" `opt_via` when appropriate
259
262
let mut err = match (
@@ -265,7 +268,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
265
268
"mutable" ,
266
269
) {
267
270
( BorrowKind :: Shared , lft, _, BorrowKind :: Mut { .. } , _, rgt)
268
- | ( BorrowKind :: Mut { .. } , _, lft, BorrowKind :: Shared , rgt, _) => self . tcx
271
+ | ( BorrowKind :: Mut { .. } , _, lft, BorrowKind :: Shared , rgt, _) => tcx
269
272
. cannot_reborrow_already_borrowed (
270
273
span,
271
274
& desc_place,
@@ -279,7 +282,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
279
282
Origin :: Mir ,
280
283
) ,
281
284
282
- ( BorrowKind :: Mut { .. } , _, _, BorrowKind :: Mut { .. } , _, _) => self . tcx
285
+ ( BorrowKind :: Mut { .. } , _, _, BorrowKind :: Mut { .. } , _, _) => tcx
283
286
. cannot_mutably_borrow_multiply (
284
287
span,
285
288
& desc_place,
@@ -290,7 +293,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
290
293
Origin :: Mir ,
291
294
) ,
292
295
293
- ( BorrowKind :: Unique , _, _, BorrowKind :: Unique , _, _) => self . tcx
296
+ ( BorrowKind :: Unique , _, _, BorrowKind :: Unique , _, _) => tcx
294
297
. cannot_uniquely_borrow_by_two_closures (
295
298
span,
296
299
& desc_place,
@@ -299,7 +302,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
299
302
Origin :: Mir ,
300
303
) ,
301
304
302
- ( BorrowKind :: Unique , _, _, _, _, _) => self . tcx . cannot_uniquely_borrow_by_one_closure (
305
+ ( BorrowKind :: Unique , _, _, _, _, _) => tcx. cannot_uniquely_borrow_by_one_closure (
303
306
span,
304
307
& desc_place,
305
308
"" ,
@@ -310,7 +313,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
310
313
Origin :: Mir ,
311
314
) ,
312
315
313
- ( BorrowKind :: Shared , lft, _, BorrowKind :: Unique , _, _) => self . tcx
316
+ ( BorrowKind :: Shared , lft, _, BorrowKind :: Unique , _, _) => tcx
314
317
. cannot_reborrow_already_uniquely_borrowed (
315
318
span,
316
319
& desc_place,
@@ -322,7 +325,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
322
325
Origin :: Mir ,
323
326
) ,
324
327
325
- ( BorrowKind :: Mut { .. } , _, lft, BorrowKind :: Unique , _, _) => self . tcx
328
+ ( BorrowKind :: Mut { .. } , _, lft, BorrowKind :: Unique , _, _) => tcx
326
329
. cannot_reborrow_already_uniquely_borrowed (
327
330
span,
328
331
& desc_place,
@@ -466,7 +469,8 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
466
469
_proper_span : Span ,
467
470
end_span : Option < Span > ,
468
471
) {
469
- let mut err = self . tcx . path_does_not_live_long_enough (
472
+ let tcx = self . tcx ;
473
+ let mut err = tcx. path_does_not_live_long_enough (
470
474
borrow_span,
471
475
& format ! ( "`{}`" , name) ,
472
476
Origin :: Mir ,
@@ -493,9 +497,9 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
493
497
proper_span : Span ,
494
498
end_span : Option < Span > ,
495
499
) {
500
+ let tcx = self . tcx ;
496
501
let mut err =
497
- self . tcx
498
- . path_does_not_live_long_enough ( proper_span, "borrowed value" , Origin :: Mir ) ;
502
+ tcx. path_does_not_live_long_enough ( proper_span, "borrowed value" , Origin :: Mir ) ;
499
503
err. span_label ( proper_span, "temporary value does not live long enough" ) ;
500
504
err. span_label (
501
505
drop_span,
@@ -527,16 +531,17 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
527
531
context, name, scope_tree, borrow, drop_span, borrow_span
528
532
) ;
529
533
530
- let mut err = self . tcx . path_does_not_live_long_enough (
534
+ let tcx = self . tcx ;
535
+ let mut err = tcx. path_does_not_live_long_enough (
531
536
borrow_span,
532
537
& format ! ( "`{}`" , name) ,
533
538
Origin :: Mir ,
534
539
) ;
535
540
err. span_label ( borrow_span, "borrowed value does not live long enough" ) ;
536
541
err. span_label ( drop_span, "borrowed value only lives until here" ) ;
537
542
538
- if !self . tcx . nll ( ) {
539
- self . tcx . note_and_explain_region (
543
+ if !tcx. nll ( ) {
544
+ tcx. note_and_explain_region (
540
545
scope_tree,
541
546
& mut err,
542
547
"borrowed value must be valid for " ,
@@ -566,14 +571,14 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
566
571
context, scope_tree, borrow, drop_span, proper_span
567
572
) ;
568
573
574
+ let tcx = self . tcx ;
569
575
let mut err =
570
- self . tcx
571
- . path_does_not_live_long_enough ( proper_span, "borrowed value" , Origin :: Mir ) ;
576
+ tcx. path_does_not_live_long_enough ( proper_span, "borrowed value" , Origin :: Mir ) ;
572
577
err. span_label ( proper_span, "temporary value does not live long enough" ) ;
573
578
err. span_label ( drop_span, "temporary value only lives until here" ) ;
574
579
575
- if !self . tcx . nll ( ) {
576
- self . tcx . note_and_explain_region (
580
+ if !tcx. nll ( ) {
581
+ tcx. note_and_explain_region (
577
582
scope_tree,
578
583
& mut err,
579
584
"borrowed value must be valid for " ,
@@ -592,7 +597,8 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
592
597
( place, span) : ( & Place < ' tcx > , Span ) ,
593
598
loan : & BorrowData < ' tcx > ,
594
599
) {
595
- let mut err = self . tcx . cannot_assign_to_borrowed (
600
+ let tcx = self . tcx ;
601
+ let mut err = tcx. cannot_assign_to_borrowed (
596
602
span,
597
603
self . retrieve_borrow_span ( loan) ,
598
604
& self . describe_place ( place) . unwrap_or ( "_" . to_owned ( ) ) ,
0 commit comments