@@ -738,7 +738,7 @@ impl DiagCtxt {
738738 #[ rustc_lint_diagnostics]
739739 #[ track_caller]
740740 pub fn struct_warn ( & self , msg : impl Into < DiagnosticMessage > ) -> DiagnosticBuilder < ' _ , ( ) > {
741- DiagnosticBuilder :: new ( self , Warning ( None ) , msg)
741+ DiagnosticBuilder :: new ( self , Warning , msg)
742742 }
743743
744744 /// Construct a builder at the `Allow` level with the `msg`.
@@ -1001,7 +1001,7 @@ impl DiagCtxt {
10011001 ( 0 , 0 ) => return ,
10021002 ( 0 , _) => inner
10031003 . emitter
1004- . emit_diagnostic ( & Diagnostic :: new ( Warning ( None ) , DiagnosticMessage :: Str ( warnings) ) ) ,
1004+ . emit_diagnostic ( & Diagnostic :: new ( Warning , DiagnosticMessage :: Str ( warnings) ) ) ,
10051005 ( _, 0 ) => {
10061006 inner. emit_diagnostic ( Diagnostic :: new ( Fatal , errors) ) ;
10071007 }
@@ -1090,7 +1090,7 @@ impl DiagCtxt {
10901090 & ' a self ,
10911091 warning : impl IntoDiagnostic < ' a , ( ) > ,
10921092 ) -> DiagnosticBuilder < ' a , ( ) > {
1093- warning. into_diagnostic ( self , Warning ( None ) )
1093+ warning. into_diagnostic ( self , Warning )
10941094 }
10951095
10961096 #[ track_caller]
@@ -1300,10 +1300,7 @@ impl DiagCtxtInner {
13001300 self . fulfilled_expectations . insert ( expectation_id. normalize ( ) ) ;
13011301 }
13021302
1303- if matches ! ( diagnostic. level, Warning ( _) )
1304- && !self . flags . can_emit_warnings
1305- && !diagnostic. is_force_warn ( )
1306- {
1303+ if diagnostic. level == Warning && !self . flags . can_emit_warnings {
13071304 return None ;
13081305 }
13091306
@@ -1351,7 +1348,7 @@ impl DiagCtxtInner {
13511348 self . emitter . emit_diagnostic ( & diagnostic) ;
13521349 if diagnostic. is_error ( ) {
13531350 self . deduplicated_err_count += 1 ;
1354- } else if let Warning ( _) = diagnostic . level {
1351+ } else if matches ! ( diagnostic . level , ForceWarning ( _) | Warning ) {
13551352 self . deduplicated_warn_count += 1 ;
13561353 }
13571354 }
@@ -1554,14 +1551,17 @@ pub enum Level {
15541551 /// Its `EmissionGuarantee` is `ErrorGuaranteed`.
15551552 Error ,
15561553
1557- /// A warning about the code being compiled. Does not prevent compilation from finishing.
1554+ /// A `force-warn` lint warning about the code being compiled. Does not prevent compilation
1555+ /// from finishing.
15581556 ///
1559- /// This [`LintExpectationId`] is used for expected lint diagnostics, which should
1560- /// also emit a warning due to the `force-warn` flag. In all other cases this should
1561- /// be `None`.
1557+ /// The [`LintExpectationId`] is used for expected lint diagnostics. In all other cases this
1558+ /// should be `None`.
1559+ ForceWarning ( Option < LintExpectationId > ) ,
1560+
1561+ /// A warning about the code being compiled. Does not prevent compilation from finishing.
15621562 ///
15631563 /// Its `EmissionGuarantee` is `()`.
1564- Warning ( Option < LintExpectationId > ) ,
1564+ Warning ,
15651565
15661566 /// A message giving additional context. Rare, because notes are more commonly attached to other
15671567 /// diagnostics such as errors.
@@ -1614,7 +1614,7 @@ impl Level {
16141614 Bug | DelayedBug | Fatal | Error => {
16151615 spec. set_fg ( Some ( Color :: Red ) ) . set_intense ( true ) ;
16161616 }
1617- Warning ( _) => {
1617+ ForceWarning ( _) | Warning => {
16181618 spec. set_fg ( Some ( Color :: Yellow ) ) . set_intense ( cfg ! ( windows) ) ;
16191619 }
16201620 Note | OnceNote => {
@@ -1633,7 +1633,7 @@ impl Level {
16331633 match self {
16341634 Bug | DelayedBug => "error: internal compiler error" ,
16351635 Fatal | Error => "error" ,
1636- Warning ( _) => "warning" ,
1636+ ForceWarning ( _) | Warning => "warning" ,
16371637 Note | OnceNote => "note" ,
16381638 Help | OnceHelp => "help" ,
16391639 FailureNote => "failure-note" ,
@@ -1647,7 +1647,7 @@ impl Level {
16471647
16481648 pub fn get_expectation_id ( & self ) -> Option < LintExpectationId > {
16491649 match self {
1650- Expect ( id) | Warning ( Some ( id) ) => Some ( * id) ,
1650+ Expect ( id) | ForceWarning ( Some ( id) ) => Some ( * id) ,
16511651 _ => None ,
16521652 }
16531653 }
0 commit comments