@@ -6,7 +6,7 @@ use std::collections::BTreeMap;
66use log:: debug;
77use rustc:: { hir:: def_id:: DefId , infer:: InferCtxt , mir:: Body , ty:: RegionVid } ;
88use rustc_data_structures:: fx:: FxHashSet ;
9- use rustc_errors:: { Diagnostic , DiagnosticBuilder , Level } ;
9+ use rustc_errors:: { Diagnostic , DiagnosticBuilder } ;
1010
1111use smallvec:: SmallVec ;
1212
@@ -258,29 +258,24 @@ impl OutlivesSuggestionBuilder {
258258 // If there is exactly one suggestable constraints, then just suggest it. Otherwise, emit a
259259 // list of diagnostics.
260260 let mut diag = if suggested. len ( ) == 1 {
261- DiagnosticBuilder :: new (
262- infcx. tcx . sess . diagnostic ( ) ,
263- Level :: Help ,
264- & match suggested. last ( ) . unwrap ( ) {
265- SuggestedConstraint :: Outlives ( a, bs) => {
266- let bs: SmallVec < [ String ; 2 ] > =
267- bs. iter ( ) . map ( |r| format ! ( "{}" , r) ) . collect ( ) ;
268- format ! ( "add bound `{}: {}`" , a, bs. join( " + " ) )
269- }
261+ infcx. tcx . sess . diagnostic ( ) . struct_help ( & match suggested. last ( ) . unwrap ( ) {
262+ SuggestedConstraint :: Outlives ( a, bs) => {
263+ let bs: SmallVec < [ String ; 2 ] > = bs. iter ( ) . map ( |r| format ! ( "{}" , r) ) . collect ( ) ;
264+ format ! ( "add bound `{}: {}`" , a, bs. join( " + " ) )
265+ }
270266
271- SuggestedConstraint :: Equal ( a, b) => {
272- format ! ( "`{}` and `{}` must be the same: replace one with the other" , a, b)
273- }
274- SuggestedConstraint :: Static ( a) => format ! ( "replace `{}` with `'static`" , a) ,
275- } ,
276- )
267+ SuggestedConstraint :: Equal ( a, b) => {
268+ format ! ( "`{}` and `{}` must be the same: replace one with the other" , a, b)
269+ }
270+ SuggestedConstraint :: Static ( a) => format ! ( "replace `{}` with `'static`" , a) ,
271+ } )
277272 } else {
278273 // Create a new diagnostic.
279- let mut diag = DiagnosticBuilder :: new (
280- infcx . tcx . sess . diagnostic ( ) ,
281- Level :: Help ,
282- "the following changes may resolve your lifetime errors" ,
283- ) ;
274+ let mut diag = infcx
275+ . tcx
276+ . sess
277+ . diagnostic ( )
278+ . struct_help ( "the following changes may resolve your lifetime errors" ) ;
284279
285280 // Add suggestions.
286281 for constraint in suggested {
0 commit comments