@@ -6,7 +6,7 @@ use std::collections::BTreeMap;
6
6
use log:: debug;
7
7
use rustc:: { hir:: def_id:: DefId , infer:: InferCtxt , mir:: Body , ty:: RegionVid } ;
8
8
use rustc_data_structures:: fx:: FxHashSet ;
9
- use rustc_errors:: { Diagnostic , DiagnosticBuilder , Level } ;
9
+ use rustc_errors:: { Diagnostic , DiagnosticBuilder } ;
10
10
11
11
use smallvec:: SmallVec ;
12
12
@@ -258,29 +258,24 @@ impl OutlivesSuggestionBuilder {
258
258
// If there is exactly one suggestable constraints, then just suggest it. Otherwise, emit a
259
259
// list of diagnostics.
260
260
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
+ }
270
266
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
+ } )
277
272
} else {
278
273
// 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" ) ;
284
279
285
280
// Add suggestions.
286
281
for constraint in suggested {
0 commit comments