@@ -738,7 +738,7 @@ impl DiagCtxt {
738
738
#[ rustc_lint_diagnostics]
739
739
#[ track_caller]
740
740
pub fn struct_warn ( & self , msg : impl Into < DiagnosticMessage > ) -> DiagnosticBuilder < ' _ , ( ) > {
741
- DiagnosticBuilder :: new ( self , Warning ( None ) , msg)
741
+ DiagnosticBuilder :: new ( self , Warning , msg)
742
742
}
743
743
744
744
/// Construct a builder at the `Allow` level with the `msg`.
@@ -1005,7 +1005,7 @@ impl DiagCtxt {
1005
1005
( 0 , 0 ) => return ,
1006
1006
( 0 , _) => inner
1007
1007
. emitter
1008
- . emit_diagnostic ( & Diagnostic :: new ( Warning ( None ) , DiagnosticMessage :: Str ( warnings) ) ) ,
1008
+ . emit_diagnostic ( & Diagnostic :: new ( Warning , DiagnosticMessage :: Str ( warnings) ) ) ,
1009
1009
( _, 0 ) => {
1010
1010
inner. emit_diagnostic ( Diagnostic :: new ( Fatal , errors) ) ;
1011
1011
}
@@ -1094,7 +1094,7 @@ impl DiagCtxt {
1094
1094
& ' a self ,
1095
1095
warning : impl IntoDiagnostic < ' a , ( ) > ,
1096
1096
) -> DiagnosticBuilder < ' a , ( ) > {
1097
- warning. into_diagnostic ( self , Warning ( None ) )
1097
+ warning. into_diagnostic ( self , Warning )
1098
1098
}
1099
1099
1100
1100
#[ track_caller]
@@ -1304,10 +1304,7 @@ impl DiagCtxtInner {
1304
1304
self . fulfilled_expectations . insert ( expectation_id. normalize ( ) ) ;
1305
1305
}
1306
1306
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 {
1311
1308
if diagnostic. has_future_breakage ( ) {
1312
1309
( * TRACK_DIAGNOSTIC ) ( diagnostic, & mut |_| { } ) ;
1313
1310
}
@@ -1359,7 +1356,7 @@ impl DiagCtxtInner {
1359
1356
self . emitter . emit_diagnostic ( & diagnostic) ;
1360
1357
if diagnostic. is_error ( ) {
1361
1358
self . deduplicated_err_count += 1 ;
1362
- } else if let Warning ( _) = diagnostic . level {
1359
+ } else if matches ! ( diagnostic . level , ForceWarning ( _) | Warning ) {
1363
1360
self . deduplicated_warn_count += 1 ;
1364
1361
}
1365
1362
}
@@ -1562,14 +1559,17 @@ pub enum Level {
1562
1559
/// Its `EmissionGuarantee` is `ErrorGuaranteed`.
1563
1560
Error ,
1564
1561
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.
1566
1564
///
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.
1570
1570
///
1571
1571
/// Its `EmissionGuarantee` is `()`.
1572
- Warning ( Option < LintExpectationId > ) ,
1572
+ Warning ,
1573
1573
1574
1574
/// A message giving additional context. Rare, because notes are more commonly attached to other
1575
1575
/// diagnostics such as errors.
@@ -1622,7 +1622,7 @@ impl Level {
1622
1622
Bug | DelayedBug | Fatal | Error => {
1623
1623
spec. set_fg ( Some ( Color :: Red ) ) . set_intense ( true ) ;
1624
1624
}
1625
- Warning ( _) => {
1625
+ ForceWarning ( _) | Warning => {
1626
1626
spec. set_fg ( Some ( Color :: Yellow ) ) . set_intense ( cfg ! ( windows) ) ;
1627
1627
}
1628
1628
Note | OnceNote => {
@@ -1641,7 +1641,7 @@ impl Level {
1641
1641
match self {
1642
1642
Bug | DelayedBug => "error: internal compiler error" ,
1643
1643
Fatal | Error => "error" ,
1644
- Warning ( _) => "warning" ,
1644
+ ForceWarning ( _) | Warning => "warning" ,
1645
1645
Note | OnceNote => "note" ,
1646
1646
Help | OnceHelp => "help" ,
1647
1647
FailureNote => "failure-note" ,
@@ -1655,7 +1655,7 @@ impl Level {
1655
1655
1656
1656
pub fn get_expectation_id ( & self ) -> Option < LintExpectationId > {
1657
1657
match self {
1658
- Expect ( id) | Warning ( Some ( id) ) => Some ( * id) ,
1658
+ Expect ( id) | ForceWarning ( Some ( id) ) => Some ( * id) ,
1659
1659
_ => None ,
1660
1660
}
1661
1661
}
0 commit comments