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)]
1
3
//! Contains utilities for generating suggestions for borrowck errors related to unsatisfied
2
4
//! outlives constraints.
3
5
@@ -7,7 +9,7 @@ use rustc_middle::ty::RegionVid;
7
9
use smallvec:: SmallVec ;
8
10
use std:: collections:: BTreeMap ;
9
11
10
- use crate :: MirBorrowckCtxt ;
12
+ use crate :: { session_diagnostics :: OnLifetimeBound , MirBorrowckCtxt } ;
11
13
12
14
use super :: { ErrorConstraintInfo , RegionName , RegionNameSource } ;
13
15
@@ -171,9 +173,7 @@ impl OutlivesSuggestionBuilder {
171
173
if let ( Some ( fr_name) , Some ( outlived_fr_name) ) = ( fr_name, outlived_fr_name)
172
174
&& !matches ! ( outlived_fr_name. source, RegionNameSource :: Static )
173
175
{
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 } ) ;
177
177
}
178
178
}
179
179
Original file line number Diff line number Diff line change @@ -337,3 +337,9 @@ pub(crate) enum MustValidFor<'a> {
337
337
span : Span ,
338
338
} ,
339
339
}
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 =
135
135
136
136
borrowck_outlive_constraint_need_borrow_for =
137
137
{ $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