@@ -19,7 +19,7 @@ use crate::borrow_check::{
19
19
MirBorrowckCtxt ,
20
20
} ;
21
21
22
- use super :: { OutlivesSuggestionBuilder , RegionErrorNamingCtx , RegionName , RegionNameSource } ;
22
+ use super :: { OutlivesSuggestionBuilder , RegionName , RegionNameSource } ;
23
23
24
24
impl ConstraintDescription for ConstraintCategory {
25
25
fn description ( & self ) -> & ' static str {
@@ -152,8 +152,6 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
152
152
// Iterate through all the errors, producing a diagnostic for each one. The diagnostics are
153
153
// buffered in the `MirBorrowckCtxt`.
154
154
155
- // TODO(mark-i-m): Would be great to get rid of the naming context.
156
- let mut region_naming = RegionErrorNamingCtx :: new ( ) ;
157
155
let mut outlives_suggestion = OutlivesSuggestionBuilder :: default ( ) ;
158
156
159
157
for nll_error in nll_errors. into_iter ( ) {
@@ -243,7 +241,6 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
243
241
fr_origin,
244
242
shorter_fr,
245
243
& mut outlives_suggestion,
246
- & mut region_naming,
247
244
) ;
248
245
} else {
249
246
// We only report the first error, so as not to overwhelm the user. See
@@ -262,7 +259,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
262
259
}
263
260
264
261
// Emit one outlives suggestions for each MIR def we borrowck
265
- outlives_suggestion. add_suggestion ( self , & mut region_naming ) ;
262
+ outlives_suggestion. add_suggestion ( self ) ;
266
263
}
267
264
268
265
/// Report an error because the universal region `fr` was required to outlive
@@ -279,7 +276,6 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
279
276
fr_origin : NLLRegionVariableOrigin ,
280
277
outlived_fr : RegionVid ,
281
278
outlives_suggestion : & mut OutlivesSuggestionBuilder ,
282
- renctx : & mut RegionErrorNamingCtx ,
283
279
) {
284
280
debug ! ( "report_error(fr={:?}, outlived_fr={:?})" , fr, outlived_fr) ;
285
281
@@ -320,21 +316,21 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
320
316
321
317
let diag = match ( category, fr_is_local, outlived_fr_is_local) {
322
318
( ConstraintCategory :: Return , true , false ) if self . is_closure_fn_mut ( fr) => {
323
- self . report_fnmut_error ( & errci, renctx )
319
+ self . report_fnmut_error ( & errci)
324
320
}
325
321
( ConstraintCategory :: Assignment , true , false )
326
322
| ( ConstraintCategory :: CallArgument , true , false ) => {
327
- let mut db = self . report_escaping_data_error ( & errci, renctx ) ;
323
+ let mut db = self . report_escaping_data_error ( & errci) ;
328
324
329
- outlives_suggestion. intermediate_suggestion ( self , & errci, renctx , & mut db) ;
325
+ outlives_suggestion. intermediate_suggestion ( self , & errci, & mut db) ;
330
326
outlives_suggestion. collect_constraint ( fr, outlived_fr) ;
331
327
332
328
db
333
329
}
334
330
_ => {
335
- let mut db = self . report_general_error ( & errci, renctx ) ;
331
+ let mut db = self . report_general_error ( & errci) ;
336
332
337
- outlives_suggestion. intermediate_suggestion ( self , & errci, renctx , & mut db) ;
333
+ outlives_suggestion. intermediate_suggestion ( self , & errci, & mut db) ;
338
334
outlives_suggestion. collect_constraint ( fr, outlived_fr) ;
339
335
340
336
db
@@ -360,11 +356,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
360
356
/// executing...
361
357
/// = note: ...therefore, returned references to captured variables will escape the closure
362
358
/// ```
363
- fn report_fnmut_error (
364
- & self ,
365
- errci : & ErrorConstraintInfo ,
366
- renctx : & mut RegionErrorNamingCtx ,
367
- ) -> DiagnosticBuilder < ' tcx > {
359
+ fn report_fnmut_error ( & self , errci : & ErrorConstraintInfo ) -> DiagnosticBuilder < ' tcx > {
368
360
let ErrorConstraintInfo { outlived_fr, span, .. } = errci;
369
361
370
362
let mut diag = self
@@ -386,7 +378,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
386
378
387
379
diag. span_label ( * span, message) ;
388
380
389
- match self . give_region_a_name ( renctx , * outlived_fr) . unwrap ( ) . source {
381
+ match self . give_region_a_name ( * outlived_fr) . unwrap ( ) . source {
390
382
RegionNameSource :: NamedEarlyBoundRegion ( fr_span)
391
383
| RegionNameSource :: NamedFreeRegion ( fr_span)
392
384
| RegionNameSource :: SynthesizedFreeEnvRegion ( fr_span, _)
@@ -421,11 +413,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
421
413
/// LL | ref_obj(x)
422
414
/// | ^^^^^^^^^^ `x` escapes the function body here
423
415
/// ```
424
- fn report_escaping_data_error (
425
- & self ,
426
- errci : & ErrorConstraintInfo ,
427
- renctx : & mut RegionErrorNamingCtx ,
428
- ) -> DiagnosticBuilder < ' tcx > {
416
+ fn report_escaping_data_error ( & self , errci : & ErrorConstraintInfo ) -> DiagnosticBuilder < ' tcx > {
429
417
let ErrorConstraintInfo { span, category, .. } = errci;
430
418
431
419
let fr_name_and_span = self . regioncx . get_var_name_and_span_for_region (
@@ -456,10 +444,11 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
456
444
|| ( * category == ConstraintCategory :: Assignment && escapes_from == "function" )
457
445
|| escapes_from == "const"
458
446
{
459
- return self . report_general_error (
460
- & ErrorConstraintInfo { fr_is_local : true , outlived_fr_is_local : false , ..* errci } ,
461
- renctx,
462
- ) ;
447
+ return self . report_general_error ( & ErrorConstraintInfo {
448
+ fr_is_local : true ,
449
+ outlived_fr_is_local : false ,
450
+ ..* errci
451
+ } ) ;
463
452
}
464
453
465
454
let mut diag =
@@ -505,11 +494,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
505
494
/// | ^^^^^^^^^^^^^^ function was supposed to return data with lifetime `'a` but it
506
495
/// | is returning data with lifetime `'b`
507
496
/// ```
508
- fn report_general_error (
509
- & self ,
510
- errci : & ErrorConstraintInfo ,
511
- renctx : & mut RegionErrorNamingCtx ,
512
- ) -> DiagnosticBuilder < ' tcx > {
497
+ fn report_general_error ( & self , errci : & ErrorConstraintInfo ) -> DiagnosticBuilder < ' tcx > {
513
498
let ErrorConstraintInfo {
514
499
fr,
515
500
fr_is_local,
@@ -526,9 +511,9 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
526
511
let mir_def_name =
527
512
if self . infcx . tcx . is_closure ( self . mir_def_id ) { "closure" } else { "function" } ;
528
513
529
- let fr_name = self . give_region_a_name ( renctx , * fr) . unwrap ( ) ;
514
+ let fr_name = self . give_region_a_name ( * fr) . unwrap ( ) ;
530
515
fr_name. highlight_region_name ( & mut diag) ;
531
- let outlived_fr_name = self . give_region_a_name ( renctx , * outlived_fr) . unwrap ( ) ;
516
+ let outlived_fr_name = self . give_region_a_name ( * outlived_fr) . unwrap ( ) ;
532
517
outlived_fr_name. highlight_region_name ( & mut diag) ;
533
518
534
519
match ( category, outlived_fr_is_local, fr_is_local) {
0 commit comments