1
+ use crate :: infer:: error_reporting:: note_and_explain_region;
1
2
use crate :: infer:: { self , InferCtxt , SubregionOrigin } ;
2
3
use crate :: middle:: region;
3
4
use crate :: ty:: error:: TypeError ;
@@ -167,8 +168,9 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
167
168
infer:: Subtype ( box trace) => {
168
169
let terr = TypeError :: RegionsDoesNotOutlive ( sup, sub) ;
169
170
let mut err = self . report_and_explain_type_error ( trace, & terr) ;
170
- self . tcx . note_and_explain_region ( region_scope_tree, & mut err, "" , sup, "..." ) ;
171
- self . tcx . note_and_explain_region (
171
+ note_and_explain_region ( self . tcx , region_scope_tree, & mut err, "" , sup, "..." ) ;
172
+ note_and_explain_region (
173
+ self . tcx ,
172
174
region_scope_tree,
173
175
& mut err,
174
176
"...does not necessarily outlive " ,
@@ -185,14 +187,16 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
185
187
"lifetime of reference outlives lifetime of \
186
188
borrowed content..."
187
189
) ;
188
- self . tcx . note_and_explain_region (
190
+ note_and_explain_region (
191
+ self . tcx ,
189
192
region_scope_tree,
190
193
& mut err,
191
194
"...the reference is valid for " ,
192
195
sub,
193
196
"..." ,
194
197
) ;
195
- self . tcx . note_and_explain_region (
198
+ note_and_explain_region (
199
+ self . tcx ,
196
200
region_scope_tree,
197
201
& mut err,
198
202
"...but the borrowed content is only valid for " ,
@@ -211,14 +215,16 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
211
215
of captured variable `{}`...",
212
216
var_name
213
217
) ;
214
- self . tcx . note_and_explain_region (
218
+ note_and_explain_region (
219
+ self . tcx ,
215
220
region_scope_tree,
216
221
& mut err,
217
222
"...the borrowed pointer is valid for " ,
218
223
sub,
219
224
"..." ,
220
225
) ;
221
- self . tcx . note_and_explain_region (
226
+ note_and_explain_region (
227
+ self . tcx ,
222
228
region_scope_tree,
223
229
& mut err,
224
230
& format ! ( "...but `{}` is only valid for " , var_name) ,
@@ -230,14 +236,16 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
230
236
infer:: InfStackClosure ( span) => {
231
237
let mut err =
232
238
struct_span_err ! ( self . tcx. sess, span, E0314 , "closure outlives stack frame" ) ;
233
- self . tcx . note_and_explain_region (
239
+ note_and_explain_region (
240
+ self . tcx ,
234
241
region_scope_tree,
235
242
& mut err,
236
243
"...the closure must be valid for " ,
237
244
sub,
238
245
"..." ,
239
246
) ;
240
- self . tcx . note_and_explain_region (
247
+ note_and_explain_region (
248
+ self . tcx ,
241
249
region_scope_tree,
242
250
& mut err,
243
251
"...but the closure's stack frame is only valid \
@@ -254,7 +262,8 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
254
262
E0315 ,
255
263
"cannot invoke closure outside of its lifetime"
256
264
) ;
257
- self . tcx . note_and_explain_region (
265
+ note_and_explain_region (
266
+ self . tcx ,
258
267
region_scope_tree,
259
268
& mut err,
260
269
"the closure is only valid for " ,
@@ -270,7 +279,8 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
270
279
E0473 ,
271
280
"dereference of reference outside its lifetime"
272
281
) ;
273
- self . tcx . note_and_explain_region (
282
+ note_and_explain_region (
283
+ self . tcx ,
274
284
region_scope_tree,
275
285
& mut err,
276
286
"the reference is only valid for " ,
@@ -288,14 +298,16 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
288
298
enclosing closure",
289
299
self . tcx. hir( ) . name( id)
290
300
) ;
291
- self . tcx . note_and_explain_region (
301
+ note_and_explain_region (
302
+ self . tcx ,
292
303
region_scope_tree,
293
304
& mut err,
294
305
"captured variable is valid for " ,
295
306
sup,
296
307
"" ,
297
308
) ;
298
- self . tcx . note_and_explain_region (
309
+ note_and_explain_region (
310
+ self . tcx ,
299
311
region_scope_tree,
300
312
& mut err,
301
313
"closure is valid for " ,
@@ -311,7 +323,8 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
311
323
E0475 ,
312
324
"index of slice outside its lifetime"
313
325
) ;
314
- self . tcx . note_and_explain_region (
326
+ note_and_explain_region (
327
+ self . tcx ,
315
328
region_scope_tree,
316
329
& mut err,
317
330
"the slice is only valid for " ,
@@ -328,14 +341,16 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
328
341
"lifetime of the source pointer does not outlive \
329
342
lifetime bound of the object type"
330
343
) ;
331
- self . tcx . note_and_explain_region (
344
+ note_and_explain_region (
345
+ self . tcx ,
332
346
region_scope_tree,
333
347
& mut err,
334
348
"object type is valid for " ,
335
349
sub,
336
350
"" ,
337
351
) ;
338
- self . tcx . note_and_explain_region (
352
+ note_and_explain_region (
353
+ self . tcx ,
339
354
region_scope_tree,
340
355
& mut err,
341
356
"source pointer is only valid for " ,
@@ -354,14 +369,16 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
354
369
self . ty_to_string( ty)
355
370
) ;
356
371
match * sub {
357
- ty:: ReStatic => self . tcx . note_and_explain_region (
372
+ ty:: ReStatic => note_and_explain_region (
373
+ self . tcx ,
358
374
region_scope_tree,
359
375
& mut err,
360
376
"type must satisfy " ,
361
377
sub,
362
378
"" ,
363
379
) ,
364
- _ => self . tcx . note_and_explain_region (
380
+ _ => note_and_explain_region (
381
+ self . tcx ,
365
382
region_scope_tree,
366
383
& mut err,
367
384
"type must outlive " ,
@@ -374,14 +391,16 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
374
391
infer:: RelateRegionParamBound ( span) => {
375
392
let mut err =
376
393
struct_span_err ! ( self . tcx. sess, span, E0478 , "lifetime bound not satisfied" ) ;
377
- self . tcx . note_and_explain_region (
394
+ note_and_explain_region (
395
+ self . tcx ,
378
396
region_scope_tree,
379
397
& mut err,
380
398
"lifetime parameter instantiated with " ,
381
399
sup,
382
400
"" ,
383
401
) ;
384
- self . tcx . note_and_explain_region (
402
+ note_and_explain_region (
403
+ self . tcx ,
385
404
region_scope_tree,
386
405
& mut err,
387
406
"but lifetime parameter must outlive " ,
@@ -399,7 +418,8 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
399
418
parameter) is not valid at this point",
400
419
self . ty_to_string( ty)
401
420
) ;
402
- self . tcx . note_and_explain_region (
421
+ note_and_explain_region (
422
+ self . tcx ,
403
423
region_scope_tree,
404
424
& mut err,
405
425
"type must outlive " ,
@@ -416,7 +436,8 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
416
436
"lifetime of method receiver does not outlive the \
417
437
method call"
418
438
) ;
419
- self . tcx . note_and_explain_region (
439
+ note_and_explain_region (
440
+ self . tcx ,
420
441
region_scope_tree,
421
442
& mut err,
422
443
"the receiver is only valid for " ,
@@ -433,7 +454,8 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
433
454
"lifetime of function argument does not outlive \
434
455
the function call"
435
456
) ;
436
- self . tcx . note_and_explain_region (
457
+ note_and_explain_region (
458
+ self . tcx ,
437
459
region_scope_tree,
438
460
& mut err,
439
461
"the function argument is only valid for " ,
@@ -450,7 +472,8 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
450
472
"lifetime of return value does not outlive the \
451
473
function call"
452
474
) ;
453
- self . tcx . note_and_explain_region (
475
+ note_and_explain_region (
476
+ self . tcx ,
454
477
region_scope_tree,
455
478
& mut err,
456
479
"the return value is only valid for " ,
@@ -467,7 +490,8 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
467
490
"lifetime of operand does not outlive the \
468
491
operation"
469
492
) ;
470
- self . tcx . note_and_explain_region (
493
+ note_and_explain_region (
494
+ self . tcx ,
471
495
region_scope_tree,
472
496
& mut err,
473
497
"the operand is only valid for " ,
@@ -483,7 +507,8 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
483
507
E0484 ,
484
508
"reference is not valid at the time of borrow"
485
509
) ;
486
- self . tcx . note_and_explain_region (
510
+ note_and_explain_region (
511
+ self . tcx ,
487
512
region_scope_tree,
488
513
& mut err,
489
514
"the borrow is only valid for " ,
@@ -500,7 +525,8 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
500
525
"automatically reference is not valid at the time \
501
526
of borrow"
502
527
) ;
503
- self . tcx . note_and_explain_region (
528
+ note_and_explain_region (
529
+ self . tcx ,
504
530
region_scope_tree,
505
531
& mut err,
506
532
"the automatic borrow is only valid for " ,
@@ -518,7 +544,8 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
518
544
not valid during the expression: `{}`",
519
545
self . ty_to_string( t)
520
546
) ;
521
- self . tcx . note_and_explain_region (
547
+ note_and_explain_region (
548
+ self . tcx ,
522
549
region_scope_tree,
523
550
& mut err,
524
551
"type is only valid for " ,
@@ -536,14 +563,16 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
536
563
called while references are dead"
537
564
) ;
538
565
// FIXME (22171): terms "super/subregion" are suboptimal
539
- self . tcx . note_and_explain_region (
566
+ note_and_explain_region (
567
+ self . tcx ,
540
568
region_scope_tree,
541
569
& mut err,
542
570
"superregion: " ,
543
571
sup,
544
572
"" ,
545
573
) ;
546
- self . tcx . note_and_explain_region (
574
+ note_and_explain_region (
575
+ self . tcx ,
547
576
region_scope_tree,
548
577
& mut err,
549
578
"subregion: " ,
@@ -560,7 +589,8 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
560
589
"lifetime of variable does not enclose its \
561
590
declaration"
562
591
) ;
563
- self . tcx . note_and_explain_region (
592
+ note_and_explain_region (
593
+ self . tcx ,
564
594
region_scope_tree,
565
595
& mut err,
566
596
"the variable is only valid for " ,
@@ -576,7 +606,8 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
576
606
E0489 ,
577
607
"type/lifetime parameter not in scope here"
578
608
) ;
579
- self . tcx . note_and_explain_region (
609
+ note_and_explain_region (
610
+ self . tcx ,
580
611
region_scope_tree,
581
612
& mut err,
582
613
"the parameter is only valid for " ,
@@ -593,14 +624,16 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
593
624
"a value of type `{}` is borrowed for too long" ,
594
625
self . ty_to_string( ty)
595
626
) ;
596
- self . tcx . note_and_explain_region (
627
+ note_and_explain_region (
628
+ self . tcx ,
597
629
region_scope_tree,
598
630
& mut err,
599
631
"the type is valid for " ,
600
632
sub,
601
633
"" ,
602
634
) ;
603
- self . tcx . note_and_explain_region (
635
+ note_and_explain_region (
636
+ self . tcx ,
604
637
region_scope_tree,
605
638
& mut err,
606
639
"but the borrow lasts for " ,
@@ -618,14 +651,16 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
618
651
than the data it references",
619
652
self . ty_to_string( ty)
620
653
) ;
621
- self . tcx . note_and_explain_region (
654
+ note_and_explain_region (
655
+ self . tcx ,
622
656
region_scope_tree,
623
657
& mut err,
624
658
"the pointer is valid for " ,
625
659
sub,
626
660
"" ,
627
661
) ;
628
- self . tcx . note_and_explain_region (
662
+ note_and_explain_region (
663
+ self . tcx ,
629
664
region_scope_tree,
630
665
& mut err,
631
666
"but the referenced data is only valid for " ,
0 commit comments