@@ -741,7 +741,7 @@ impl DiagCtxt {
741741 #[ rustc_lint_diagnostics]
742742 #[ track_caller]
743743 pub fn struct_warn ( & self , msg : impl Into < DiagnosticMessage > ) -> DiagnosticBuilder < ' _ , ( ) > {
744- DiagnosticBuilder :: new ( self , Warning ( None ) , msg)
744+ DiagnosticBuilder :: new ( self , Warning , msg)
745745 }
746746
747747 /// Construct a builder at the `Allow` level with the `msg`.
@@ -1004,7 +1004,7 @@ impl DiagCtxt {
10041004 ( 0 , 0 ) => return ,
10051005 ( 0 , _) => inner
10061006 . emitter
1007- . emit_diagnostic ( & Diagnostic :: new ( Warning ( None ) , DiagnosticMessage :: Str ( warnings) ) ) ,
1007+ . emit_diagnostic ( & Diagnostic :: new ( Warning , DiagnosticMessage :: Str ( warnings) ) ) ,
10081008 ( _, 0 ) => {
10091009 inner. emit_diagnostic ( Diagnostic :: new ( Fatal , errors) ) ;
10101010 }
@@ -1093,7 +1093,7 @@ impl DiagCtxt {
10931093 & ' a self ,
10941094 warning : impl IntoDiagnostic < ' a , ( ) > ,
10951095 ) -> DiagnosticBuilder < ' a , ( ) > {
1096- warning. into_diagnostic ( self , Warning ( None ) )
1096+ warning. into_diagnostic ( self , Warning )
10971097 }
10981098
10991099 #[ track_caller]
@@ -1303,10 +1303,7 @@ impl DiagCtxtInner {
13031303 self . fulfilled_expectations . insert ( expectation_id. normalize ( ) ) ;
13041304 }
13051305
1306- if matches ! ( diagnostic. level, Warning ( _) )
1307- && !self . flags . can_emit_warnings
1308- && !diagnostic. is_force_warn ( )
1309- {
1306+ if diagnostic. level == Warning && !self . flags . can_emit_warnings {
13101307 return None ;
13111308 }
13121309
@@ -1354,7 +1351,7 @@ impl DiagCtxtInner {
13541351 self . emitter . emit_diagnostic ( & diagnostic) ;
13551352 if diagnostic. is_error ( ) {
13561353 self . deduplicated_err_count += 1 ;
1357- } else if let Warning ( _) = diagnostic . level {
1354+ } else if matches ! ( diagnostic . level , ForceWarning ( _) | Warning ) {
13581355 self . deduplicated_warn_count += 1 ;
13591356 }
13601357 }
@@ -1557,14 +1554,17 @@ pub enum Level {
15571554 /// Its `EmissionGuarantee` is `ErrorGuaranteed`.
15581555 Error ,
15591556
1560- /// A warning about the code being compiled. Does not prevent compilation from finishing.
1557+ /// A `force-warn` lint warning about the code being compiled. Does not prevent compilation
1558+ /// from finishing.
15611559 ///
1562- /// This [`LintExpectationId`] is used for expected lint diagnostics, which should
1563- /// also emit a warning due to the `force-warn` flag. In all other cases this should
1564- /// be `None`.
1560+ /// The [`LintExpectationId`] is used for expected lint diagnostics. In all other cases this
1561+ /// should be `None`.
1562+ ForceWarning ( Option < LintExpectationId > ) ,
1563+
1564+ /// A warning about the code being compiled. Does not prevent compilation from finishing.
15651565 ///
15661566 /// Its `EmissionGuarantee` is `()`.
1567- Warning ( Option < LintExpectationId > ) ,
1567+ Warning ,
15681568
15691569 /// A message giving additional context. Rare, because notes are more commonly attached to other
15701570 /// diagnostics such as errors.
@@ -1617,7 +1617,7 @@ impl Level {
16171617 Bug | DelayedBug | Fatal | Error => {
16181618 spec. set_fg ( Some ( Color :: Red ) ) . set_intense ( true ) ;
16191619 }
1620- Warning ( _) => {
1620+ ForceWarning ( _) | Warning => {
16211621 spec. set_fg ( Some ( Color :: Yellow ) ) . set_intense ( cfg ! ( windows) ) ;
16221622 }
16231623 Note | OnceNote => {
@@ -1636,7 +1636,7 @@ impl Level {
16361636 match self {
16371637 Bug | DelayedBug => "error: internal compiler error" ,
16381638 Fatal | Error => "error" ,
1639- Warning ( _) => "warning" ,
1639+ ForceWarning ( _) | Warning => "warning" ,
16401640 Note | OnceNote => "note" ,
16411641 Help | OnceHelp => "help" ,
16421642 FailureNote => "failure-note" ,
@@ -1650,7 +1650,7 @@ impl Level {
16501650
16511651 pub fn get_expectation_id ( & self ) -> Option < LintExpectationId > {
16521652 match self {
1653- Expect ( id) | Warning ( Some ( id) ) => Some ( * id) ,
1653+ Expect ( id) | ForceWarning ( Some ( id) ) => Some ( * id) ,
16541654 _ => None ,
16551655 }
16561656 }
0 commit comments