@@ -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`.
@@ -1005,7 +1005,7 @@ impl DiagCtxt {
10051005 ( 0 , 0 ) => return ,
10061006 ( 0 , _) => inner
10071007 . emitter
1008- . emit_diagnostic ( & Diagnostic :: new ( Warning ( None ) , DiagnosticMessage :: Str ( warnings) ) ) ,
1008+ . emit_diagnostic ( & Diagnostic :: new ( Warning , DiagnosticMessage :: Str ( warnings) ) ) ,
10091009 ( _, 0 ) => {
10101010 inner. emit_diagnostic ( Diagnostic :: new ( Fatal , errors) ) ;
10111011 }
@@ -1094,7 +1094,7 @@ impl DiagCtxt {
10941094 & ' a self ,
10951095 warning : impl IntoDiagnostic < ' a , ( ) > ,
10961096 ) -> DiagnosticBuilder < ' a , ( ) > {
1097- warning. into_diagnostic ( self , Warning ( None ) )
1097+ warning. into_diagnostic ( self , Warning )
10981098 }
10991099
11001100 #[ track_caller]
@@ -1304,10 +1304,7 @@ impl DiagCtxtInner {
13041304 self . fulfilled_expectations . insert ( expectation_id. normalize ( ) ) ;
13051305 }
13061306
1307- if matches ! ( diagnostic. level, Warning ( _) )
1308- && !self . flags . can_emit_warnings
1309- && !diagnostic. is_force_warn ( )
1310- {
1307+ if diagnostic. level == Warning && !self . flags . can_emit_warnings {
13111308 if diagnostic. has_future_breakage ( ) {
13121309 ( * TRACK_DIAGNOSTIC ) ( diagnostic, & mut |_| { } ) ;
13131310 }
@@ -1359,7 +1356,7 @@ impl DiagCtxtInner {
13591356 self . emitter . emit_diagnostic ( & diagnostic) ;
13601357 if diagnostic. is_error ( ) {
13611358 self . deduplicated_err_count += 1 ;
1362- } else if let Warning ( _) = diagnostic . level {
1359+ } else if matches ! ( diagnostic . level , ForceWarning ( _) | Warning ) {
13631360 self . deduplicated_warn_count += 1 ;
13641361 }
13651362 }
@@ -1562,14 +1559,17 @@ pub enum Level {
15621559 /// Its `EmissionGuarantee` is `ErrorGuaranteed`.
15631560 Error ,
15641561
1565- /// A warning about the code being compiled. Does not prevent compilation from finishing.
1562+ /// A `force-warn` lint warning about the code being compiled. Does not prevent compilation
1563+ /// from finishing.
15661564 ///
1567- /// This [`LintExpectationId`] is used for expected lint diagnostics, which should
1568- /// also emit a warning due to the `force-warn` flag. In all other cases this should
1569- /// be `None`.
1565+ /// The [`LintExpectationId`] is used for expected lint diagnostics. In all other cases this
1566+ /// should be `None`.
1567+ ForceWarning ( Option < LintExpectationId > ) ,
1568+
1569+ /// A warning about the code being compiled. Does not prevent compilation from finishing.
15701570 ///
15711571 /// Its `EmissionGuarantee` is `()`.
1572- Warning ( Option < LintExpectationId > ) ,
1572+ Warning ,
15731573
15741574 /// A message giving additional context. Rare, because notes are more commonly attached to other
15751575 /// diagnostics such as errors.
@@ -1622,7 +1622,7 @@ impl Level {
16221622 Bug | DelayedBug | Fatal | Error => {
16231623 spec. set_fg ( Some ( Color :: Red ) ) . set_intense ( true ) ;
16241624 }
1625- Warning ( _) => {
1625+ ForceWarning ( _) | Warning => {
16261626 spec. set_fg ( Some ( Color :: Yellow ) ) . set_intense ( cfg ! ( windows) ) ;
16271627 }
16281628 Note | OnceNote => {
@@ -1641,7 +1641,7 @@ impl Level {
16411641 match self {
16421642 Bug | DelayedBug => "error: internal compiler error" ,
16431643 Fatal | Error => "error" ,
1644- Warning ( _) => "warning" ,
1644+ ForceWarning ( _) | Warning => "warning" ,
16451645 Note | OnceNote => "note" ,
16461646 Help | OnceHelp => "help" ,
16471647 FailureNote => "failure-note" ,
@@ -1655,7 +1655,7 @@ impl Level {
16551655
16561656 pub fn get_expectation_id ( & self ) -> Option < LintExpectationId > {
16571657 match self {
1658- Expect ( id) | Warning ( Some ( id) ) => Some ( * id) ,
1658+ Expect ( id) | ForceWarning ( Some ( id) ) => Some ( * id) ,
16591659 _ => None ,
16601660 }
16611661 }
0 commit comments