@@ -113,7 +113,6 @@ impl std::fmt::Display for DisplayDiagnostics<'_> {
113113
114114 for diag in self . diagnostics {
115115 let ( severity, severity_style) = match diag. severity ( ) {
116- Severity :: Help => ( "help" , stylesheet. info ) ,
117116 Severity :: Info => ( "info" , stylesheet. info ) ,
118117 Severity :: Warning => ( "warning" , stylesheet. warning ) ,
119118 Severity :: Error => ( "error" , stylesheet. error ) ,
@@ -258,7 +257,7 @@ impl<'a> Resolved<'a> {
258257/// both.)
259258#[ derive( Debug ) ]
260259struct ResolvedDiagnostic < ' a > {
261- severity : Severity ,
260+ level : AnnotateLevel ,
262261 id : Option < String > ,
263262 message : String ,
264263 annotations : Vec < ResolvedAnnotation < ' a > > ,
@@ -283,7 +282,7 @@ impl<'a> ResolvedDiagnostic<'a> {
283282 let id = Some ( diag. inner . id . to_string ( ) ) ;
284283 let message = diag. inner . message . as_str ( ) . to_string ( ) ;
285284 ResolvedDiagnostic {
286- severity : diag. inner . severity ,
285+ level : diag. inner . severity . to_annotate ( ) ,
287286 id,
288287 message,
289288 annotations,
@@ -306,7 +305,7 @@ impl<'a> ResolvedDiagnostic<'a> {
306305 } )
307306 . collect ( ) ;
308307 ResolvedDiagnostic {
309- severity : diag. inner . severity ,
308+ level : diag. inner . severity . to_annotate ( ) ,
310309 id : None ,
311310 message : diag. inner . message . as_str ( ) . to_string ( ) ,
312311 annotations,
@@ -373,7 +372,7 @@ impl<'a> ResolvedDiagnostic<'a> {
373372 snippets_by_input
374373 . sort_by ( |snips1, snips2| snips1. has_primary . cmp ( & snips2. has_primary ) . reverse ( ) ) ;
375374 RenderableDiagnostic {
376- severity : self . severity ,
375+ level : self . level ,
377376 id : self . id . as_deref ( ) ,
378377 message : & self . message ,
379378 snippets_by_input,
@@ -461,7 +460,7 @@ struct Renderable<'r> {
461460#[ derive( Debug ) ]
462461struct RenderableDiagnostic < ' r > {
463462 /// The severity of the diagnostic.
464- severity : Severity ,
463+ level : AnnotateLevel ,
465464 /// The ID of the diagnostic. The ID can usually be used on the CLI or in a
466465 /// config file to change the severity of a lint.
467466 ///
@@ -480,15 +479,14 @@ struct RenderableDiagnostic<'r> {
480479impl RenderableDiagnostic < ' _ > {
481480 /// Convert this to an "annotate" snippet.
482481 fn to_annotate ( & self ) -> AnnotateMessage < ' _ > {
483- let level = self . severity . to_annotate ( ) ;
484482 let snippets = self . snippets_by_input . iter ( ) . flat_map ( |snippets| {
485483 let path = snippets. path ;
486484 snippets
487485 . snippets
488486 . iter ( )
489487 . map ( |snippet| snippet. to_annotate ( path) )
490488 } ) ;
491- let mut message = level. title ( self . message ) ;
489+ let mut message = self . level . title ( self . message ) ;
492490 if let Some ( id) = self . id {
493491 message = message. id ( id) ;
494492 }
@@ -868,6 +866,7 @@ mod tests {
868866
869867 use crate :: diagnostic:: {
870868 Annotation , DiagnosticId , IntoDiagnosticMessage , SecondaryCode , Severity , Span ,
869+ SubDiagnosticSeverity ,
871870 } ;
872871 use crate :: files:: system_path_to_file;
873872 use crate :: system:: { DbWithWritableSystem , SystemPath } ;
@@ -1552,7 +1551,7 @@ watermelon
15521551
15531552 let mut diag = env. err ( ) . primary ( "animals" , "3" , "3" , "" ) . build ( ) ;
15541553 diag. sub (
1555- env. sub_builder ( Severity :: Info , "this is a helpful note" )
1554+ env. sub_builder ( SubDiagnosticSeverity :: Info , "this is a helpful note" )
15561555 . build ( ) ,
15571556 ) ;
15581557 insta:: assert_snapshot!(
@@ -1581,15 +1580,15 @@ watermelon
15811580
15821581 let mut diag = env. err ( ) . primary ( "animals" , "3" , "3" , "" ) . build ( ) ;
15831582 diag. sub (
1584- env. sub_builder ( Severity :: Info , "this is a helpful note" )
1583+ env. sub_builder ( SubDiagnosticSeverity :: Info , "this is a helpful note" )
15851584 . build ( ) ,
15861585 ) ;
15871586 diag. sub (
1588- env. sub_builder ( Severity :: Info , "another helpful note" )
1587+ env. sub_builder ( SubDiagnosticSeverity :: Info , "another helpful note" )
15891588 . build ( ) ,
15901589 ) ;
15911590 diag. sub (
1592- env. sub_builder ( Severity :: Info , "and another helpful note" )
1591+ env. sub_builder ( SubDiagnosticSeverity :: Info , "and another helpful note" )
15931592 . build ( ) ,
15941593 ) ;
15951594 insta:: assert_snapshot!(
@@ -2374,7 +2373,7 @@ watermelon
23742373 /// sub-diagnostic with "error" severity and canned values for
23752374 /// its identifier and message.
23762375 fn sub_warn ( & mut self ) -> SubDiagnosticBuilder < ' _ > {
2377- self . sub_builder ( Severity :: Warning , "sub-diagnostic message" )
2376+ self . sub_builder ( SubDiagnosticSeverity :: Warning , "sub-diagnostic message" )
23782377 }
23792378
23802379 /// Returns a builder for tersely constructing diagnostics.
@@ -2395,7 +2394,11 @@ watermelon
23952394 }
23962395
23972396 /// Returns a builder for tersely constructing sub-diagnostics.
2398- fn sub_builder ( & mut self , severity : Severity , message : & str ) -> SubDiagnosticBuilder < ' _ > {
2397+ fn sub_builder (
2398+ & mut self ,
2399+ severity : SubDiagnosticSeverity ,
2400+ message : & str ,
2401+ ) -> SubDiagnosticBuilder < ' _ > {
23992402 let subdiag = SubDiagnostic :: new ( severity, message) ;
24002403 SubDiagnosticBuilder { env : self , subdiag }
24012404 }
0 commit comments