@@ -741,7 +741,7 @@ impl DiagCtxt {
741
741
#[ rustc_lint_diagnostics]
742
742
#[ track_caller]
743
743
pub fn struct_warn ( & self , msg : impl Into < DiagnosticMessage > ) -> DiagnosticBuilder < ' _ , ( ) > {
744
- DiagnosticBuilder :: new ( self , Warning ( None ) , msg)
744
+ DiagnosticBuilder :: new ( self , Warning , msg)
745
745
}
746
746
747
747
/// Construct a builder at the `Allow` level with the `msg`.
@@ -1004,7 +1004,7 @@ impl DiagCtxt {
1004
1004
( 0 , 0 ) => return ,
1005
1005
( 0 , _) => inner
1006
1006
. emitter
1007
- . emit_diagnostic ( & Diagnostic :: new ( Warning ( None ) , DiagnosticMessage :: Str ( warnings) ) ) ,
1007
+ . emit_diagnostic ( & Diagnostic :: new ( Warning , DiagnosticMessage :: Str ( warnings) ) ) ,
1008
1008
( _, 0 ) => {
1009
1009
inner. emit_diagnostic ( Diagnostic :: new ( Fatal , errors) ) ;
1010
1010
}
@@ -1093,7 +1093,7 @@ impl DiagCtxt {
1093
1093
& ' a self ,
1094
1094
warning : impl IntoDiagnostic < ' a , ( ) > ,
1095
1095
) -> DiagnosticBuilder < ' a , ( ) > {
1096
- warning. into_diagnostic ( self , Warning ( None ) )
1096
+ warning. into_diagnostic ( self , Warning )
1097
1097
}
1098
1098
1099
1099
#[ track_caller]
@@ -1303,10 +1303,7 @@ impl DiagCtxtInner {
1303
1303
self . fulfilled_expectations . insert ( expectation_id. normalize ( ) ) ;
1304
1304
}
1305
1305
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 {
1310
1307
return None ;
1311
1308
}
1312
1309
@@ -1354,7 +1351,7 @@ impl DiagCtxtInner {
1354
1351
self . emitter . emit_diagnostic ( & diagnostic) ;
1355
1352
if diagnostic. is_error ( ) {
1356
1353
self . deduplicated_err_count += 1 ;
1357
- } else if let Warning ( _) = diagnostic . level {
1354
+ } else if matches ! ( diagnostic . level , ForceWarning ( _) | Warning ) {
1358
1355
self . deduplicated_warn_count += 1 ;
1359
1356
}
1360
1357
}
@@ -1557,14 +1554,17 @@ pub enum Level {
1557
1554
/// Its `EmissionGuarantee` is `ErrorGuaranteed`.
1558
1555
Error ,
1559
1556
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.
1561
1559
///
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.
1565
1565
///
1566
1566
/// Its `EmissionGuarantee` is `()`.
1567
- Warning ( Option < LintExpectationId > ) ,
1567
+ Warning ,
1568
1568
1569
1569
/// A message giving additional context. Rare, because notes are more commonly attached to other
1570
1570
/// diagnostics such as errors.
@@ -1617,7 +1617,7 @@ impl Level {
1617
1617
Bug | DelayedBug | Fatal | Error => {
1618
1618
spec. set_fg ( Some ( Color :: Red ) ) . set_intense ( true ) ;
1619
1619
}
1620
- Warning ( _) => {
1620
+ ForceWarning ( _) | Warning => {
1621
1621
spec. set_fg ( Some ( Color :: Yellow ) ) . set_intense ( cfg ! ( windows) ) ;
1622
1622
}
1623
1623
Note | OnceNote => {
@@ -1636,7 +1636,7 @@ impl Level {
1636
1636
match self {
1637
1637
Bug | DelayedBug => "error: internal compiler error" ,
1638
1638
Fatal | Error => "error" ,
1639
- Warning ( _) => "warning" ,
1639
+ ForceWarning ( _) | Warning => "warning" ,
1640
1640
Note | OnceNote => "note" ,
1641
1641
Help | OnceHelp => "help" ,
1642
1642
FailureNote => "failure-note" ,
@@ -1650,7 +1650,7 @@ impl Level {
1650
1650
1651
1651
pub fn get_expectation_id ( & self ) -> Option < LintExpectationId > {
1652
1652
match self {
1653
- Expect ( id) | Warning ( Some ( id) ) => Some ( * id) ,
1653
+ Expect ( id) | ForceWarning ( Some ( id) ) => Some ( * id) ,
1654
1654
_ => None ,
1655
1655
}
1656
1656
}
0 commit comments