@@ -304,6 +304,24 @@ impl Diagnostic {
304
304
msg : & str ,
305
305
suggestion : String ,
306
306
applicability : Applicability ,
307
+ ) -> & mut Self {
308
+ self . span_suggestion_with_style (
309
+ sp,
310
+ msg,
311
+ suggestion,
312
+ applicability,
313
+ SuggestionStyle :: ShowCode ,
314
+ ) ;
315
+ self
316
+ }
317
+
318
+ pub fn span_suggestion_with_style (
319
+ & mut self ,
320
+ sp : Span ,
321
+ msg : & str ,
322
+ suggestion : String ,
323
+ applicability : Applicability ,
324
+ style : SuggestionStyle ,
307
325
) -> & mut Self {
308
326
self . suggestions . push ( CodeSuggestion {
309
327
substitutions : vec ! [ Substitution {
@@ -313,7 +331,7 @@ impl Diagnostic {
313
331
} ] ,
314
332
} ] ,
315
333
msg : msg. to_owned ( ) ,
316
- style : SuggestionStyle :: ShowCode ,
334
+ style,
317
335
applicability,
318
336
} ) ;
319
337
self
@@ -326,17 +344,13 @@ impl Diagnostic {
326
344
suggestion : String ,
327
345
applicability : Applicability ,
328
346
) -> & mut Self {
329
- self . suggestions . push ( CodeSuggestion {
330
- substitutions : vec ! [ Substitution {
331
- parts: vec![ SubstitutionPart {
332
- snippet: suggestion,
333
- span: sp,
334
- } ] ,
335
- } ] ,
336
- msg : msg. to_owned ( ) ,
337
- style : SuggestionStyle :: ShowAlways ,
347
+ self . span_suggestion_with_style (
348
+ sp,
349
+ msg,
350
+ suggestion,
338
351
applicability,
339
- } ) ;
352
+ SuggestionStyle :: ShowAlways ,
353
+ ) ;
340
354
self
341
355
}
342
356
@@ -369,17 +383,13 @@ impl Diagnostic {
369
383
pub fn span_suggestion_short (
370
384
& mut self , sp : Span , msg : & str , suggestion : String , applicability : Applicability
371
385
) -> & mut Self {
372
- self . suggestions . push ( CodeSuggestion {
373
- substitutions : vec ! [ Substitution {
374
- parts: vec![ SubstitutionPart {
375
- snippet: suggestion,
376
- span: sp,
377
- } ] ,
378
- } ] ,
379
- msg : msg. to_owned ( ) ,
380
- style : SuggestionStyle :: HideCodeInline ,
386
+ self . span_suggestion_with_style (
387
+ sp,
388
+ msg,
389
+ suggestion,
381
390
applicability,
382
- } ) ;
391
+ SuggestionStyle :: HideCodeInline ,
392
+ ) ;
383
393
self
384
394
}
385
395
@@ -392,17 +402,13 @@ impl Diagnostic {
392
402
pub fn span_suggestion_hidden (
393
403
& mut self , sp : Span , msg : & str , suggestion : String , applicability : Applicability
394
404
) -> & mut Self {
395
- self . suggestions . push ( CodeSuggestion {
396
- substitutions : vec ! [ Substitution {
397
- parts: vec![ SubstitutionPart {
398
- snippet: suggestion,
399
- span: sp,
400
- } ] ,
401
- } ] ,
402
- msg : msg. to_owned ( ) ,
403
- style : SuggestionStyle :: HideCodeAlways ,
405
+ self . span_suggestion_with_style (
406
+ sp,
407
+ msg,
408
+ suggestion,
404
409
applicability,
405
- } ) ;
410
+ SuggestionStyle :: HideCodeAlways ,
411
+ ) ;
406
412
self
407
413
}
408
414
@@ -413,17 +419,13 @@ impl Diagnostic {
413
419
pub fn tool_only_span_suggestion (
414
420
& mut self , sp : Span , msg : & str , suggestion : String , applicability : Applicability
415
421
) -> & mut Self {
416
- self . suggestions . push ( CodeSuggestion {
417
- substitutions : vec ! [ Substitution {
418
- parts: vec![ SubstitutionPart {
419
- snippet: suggestion,
420
- span: sp,
421
- } ] ,
422
- } ] ,
423
- msg : msg. to_owned ( ) ,
424
- style : SuggestionStyle :: CompletelyHidden ,
422
+ self . span_suggestion_with_style (
423
+ sp,
424
+ msg,
425
+ suggestion,
425
426
applicability,
426
- } ) ;
427
+ SuggestionStyle :: CompletelyHidden ,
428
+ ) ;
427
429
self
428
430
}
429
431
0 commit comments