File tree Expand file tree Collapse file tree 3 files changed +13
-4
lines changed
rustc_error_messages/locales/en-US Expand file tree Collapse file tree 3 files changed +13
-4
lines changed Original file line number Diff line number Diff line change 1+ // #![deny(rustc::untranslatable_diagnostic)]
2+ // #![deny(rustc::diagnostic_outside_of_impl)]
13//! Contains utilities for generating suggestions for borrowck errors related to unsatisfied
24//! outlives constraints.
35
@@ -7,7 +9,7 @@ use rustc_middle::ty::RegionVid;
79use smallvec:: SmallVec ;
810use std:: collections:: BTreeMap ;
911
10- use crate :: MirBorrowckCtxt ;
12+ use crate :: { session_diagnostics :: OnLifetimeBound , MirBorrowckCtxt } ;
1113
1214use super :: { ErrorConstraintInfo , RegionName , RegionNameSource } ;
1315
@@ -171,9 +173,7 @@ impl OutlivesSuggestionBuilder {
171173 if let ( Some ( fr_name) , Some ( outlived_fr_name) ) = ( fr_name, outlived_fr_name)
172174 && !matches ! ( outlived_fr_name. source, RegionNameSource :: Static )
173175 {
174- diag. help ( & format ! (
175- "consider adding the following bound: `{fr_name}: {outlived_fr_name}`" ,
176- ) ) ;
176+ diag. subdiagnostic ( OnLifetimeBound :: Add { fr_name : & fr_name, outlived_fr_name : & outlived_fr_name } ) ;
177177 }
178178 }
179179
Original file line number Diff line number Diff line change @@ -337,3 +337,9 @@ pub(crate) enum MustValidFor<'a> {
337337 span : Span ,
338338 } ,
339339}
340+
341+ #[ derive( SessionSubdiagnostic ) ]
342+ pub ( crate ) enum OnLifetimeBound < ' a > {
343+ #[ help( borrowck:: consider_add_lifetime_bound) ]
344+ Add { fr_name : & ' a RegionName , outlived_fr_name : & ' a RegionName } ,
345+ }
Original file line number Diff line number Diff line change @@ -135,3 +135,6 @@ borrowck_perhaps_save_in_new_local_to_drop =
135135
136136borrowck_outlive_constraint_need_borrow_for =
137137 { $category } requires that `{ $desc } ` is borrowed for `{ $region_name } `
138+
139+ borrowck_consider_add_lifetime_bound =
140+ consider adding the following bound: `{ $fr_name } : { $outlived_fr_name } `
You can’t perform that action at this time.
0 commit comments