@@ -19,7 +19,7 @@ use crate::borrow_check::{
1919 MirBorrowckCtxt ,
2020} ;
2121
22- use super :: { OutlivesSuggestionBuilder , RegionErrorNamingCtx , RegionName , RegionNameSource } ;
22+ use super :: { OutlivesSuggestionBuilder , RegionName , RegionNameSource } ;
2323
2424impl ConstraintDescription for ConstraintCategory {
2525 fn description ( & self ) -> & ' static str {
@@ -152,8 +152,6 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
152152 // Iterate through all the errors, producing a diagnostic for each one. The diagnostics are
153153 // buffered in the `MirBorrowckCtxt`.
154154
155- // TODO(mark-i-m): Would be great to get rid of the naming context.
156- let mut region_naming = RegionErrorNamingCtx :: new ( ) ;
157155 let mut outlives_suggestion = OutlivesSuggestionBuilder :: default ( ) ;
158156
159157 for nll_error in nll_errors. into_iter ( ) {
@@ -243,7 +241,6 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
243241 fr_origin,
244242 shorter_fr,
245243 & mut outlives_suggestion,
246- & mut region_naming,
247244 ) ;
248245 } else {
249246 // We only report the first error, so as not to overwhelm the user. See
@@ -262,7 +259,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
262259 }
263260
264261 // 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 ) ;
266263 }
267264
268265 /// Report an error because the universal region `fr` was required to outlive
@@ -279,7 +276,6 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
279276 fr_origin : NLLRegionVariableOrigin ,
280277 outlived_fr : RegionVid ,
281278 outlives_suggestion : & mut OutlivesSuggestionBuilder ,
282- renctx : & mut RegionErrorNamingCtx ,
283279 ) {
284280 debug ! ( "report_error(fr={:?}, outlived_fr={:?})" , fr, outlived_fr) ;
285281
@@ -320,21 +316,21 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
320316
321317 let diag = match ( category, fr_is_local, outlived_fr_is_local) {
322318 ( ConstraintCategory :: Return , true , false ) if self . is_closure_fn_mut ( fr) => {
323- self . report_fnmut_error ( & errci, renctx )
319+ self . report_fnmut_error ( & errci)
324320 }
325321 ( ConstraintCategory :: Assignment , true , false )
326322 | ( 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) ;
328324
329- outlives_suggestion. intermediate_suggestion ( self , & errci, renctx , & mut db) ;
325+ outlives_suggestion. intermediate_suggestion ( self , & errci, & mut db) ;
330326 outlives_suggestion. collect_constraint ( fr, outlived_fr) ;
331327
332328 db
333329 }
334330 _ => {
335- let mut db = self . report_general_error ( & errci, renctx ) ;
331+ let mut db = self . report_general_error ( & errci) ;
336332
337- outlives_suggestion. intermediate_suggestion ( self , & errci, renctx , & mut db) ;
333+ outlives_suggestion. intermediate_suggestion ( self , & errci, & mut db) ;
338334 outlives_suggestion. collect_constraint ( fr, outlived_fr) ;
339335
340336 db
@@ -360,11 +356,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
360356 /// executing...
361357 /// = note: ...therefore, returned references to captured variables will escape the closure
362358 /// ```
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 > {
368360 let ErrorConstraintInfo { outlived_fr, span, .. } = errci;
369361
370362 let mut diag = self
@@ -386,7 +378,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
386378
387379 diag. span_label ( * span, message) ;
388380
389- match self . give_region_a_name ( renctx , * outlived_fr) . unwrap ( ) . source {
381+ match self . give_region_a_name ( * outlived_fr) . unwrap ( ) . source {
390382 RegionNameSource :: NamedEarlyBoundRegion ( fr_span)
391383 | RegionNameSource :: NamedFreeRegion ( fr_span)
392384 | RegionNameSource :: SynthesizedFreeEnvRegion ( fr_span, _)
@@ -421,11 +413,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
421413 /// LL | ref_obj(x)
422414 /// | ^^^^^^^^^^ `x` escapes the function body here
423415 /// ```
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 > {
429417 let ErrorConstraintInfo { span, category, .. } = errci;
430418
431419 let fr_name_and_span = self . regioncx . get_var_name_and_span_for_region (
@@ -456,10 +444,11 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
456444 || ( * category == ConstraintCategory :: Assignment && escapes_from == "function" )
457445 || escapes_from == "const"
458446 {
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+ } ) ;
463452 }
464453
465454 let mut diag =
@@ -505,11 +494,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
505494 /// | ^^^^^^^^^^^^^^ function was supposed to return data with lifetime `'a` but it
506495 /// | is returning data with lifetime `'b`
507496 /// ```
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 > {
513498 let ErrorConstraintInfo {
514499 fr,
515500 fr_is_local,
@@ -526,9 +511,9 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
526511 let mir_def_name =
527512 if self . infcx . tcx . is_closure ( self . mir_def_id ) { "closure" } else { "function" } ;
528513
529- let fr_name = self . give_region_a_name ( renctx , * fr) . unwrap ( ) ;
514+ let fr_name = self . give_region_a_name ( * fr) . unwrap ( ) ;
530515 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 ( ) ;
532517 outlived_fr_name. highlight_region_name ( & mut diag) ;
533518
534519 match ( category, outlived_fr_is_local, fr_is_local) {
0 commit comments