@@ -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`.
@@ -1001,7 +1001,7 @@ impl DiagCtxt {
1001
1001
( 0 , 0 ) => return ,
1002
1002
( 0 , _) => inner
1003
1003
. emitter
1004
- . emit_diagnostic ( & Diagnostic :: new ( Warning ( None ) , DiagnosticMessage :: Str ( warnings) ) ) ,
1004
+ . emit_diagnostic ( & Diagnostic :: new ( Warning , DiagnosticMessage :: Str ( warnings) ) ) ,
1005
1005
( _, 0 ) => {
1006
1006
inner. emit_diagnostic ( Diagnostic :: new ( Fatal , errors) ) ;
1007
1007
}
@@ -1090,7 +1090,7 @@ impl DiagCtxt {
1090
1090
& ' a self ,
1091
1091
warning : impl IntoDiagnostic < ' a , ( ) > ,
1092
1092
) -> DiagnosticBuilder < ' a , ( ) > {
1093
- warning. into_diagnostic ( self , Warning ( None ) )
1093
+ warning. into_diagnostic ( self , Warning )
1094
1094
}
1095
1095
1096
1096
#[ track_caller]
@@ -1300,10 +1300,7 @@ impl DiagCtxtInner {
1300
1300
self . fulfilled_expectations . insert ( expectation_id. normalize ( ) ) ;
1301
1301
}
1302
1302
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 {
1307
1304
return None ;
1308
1305
}
1309
1306
@@ -1351,7 +1348,7 @@ impl DiagCtxtInner {
1351
1348
self . emitter . emit_diagnostic ( & diagnostic) ;
1352
1349
if diagnostic. is_error ( ) {
1353
1350
self . deduplicated_err_count += 1 ;
1354
- } else if let Warning ( _) = diagnostic . level {
1351
+ } else if matches ! ( diagnostic . level , ForceWarning ( _) | Warning ) {
1355
1352
self . deduplicated_warn_count += 1 ;
1356
1353
}
1357
1354
}
@@ -1554,14 +1551,17 @@ pub enum Level {
1554
1551
/// Its `EmissionGuarantee` is `ErrorGuaranteed`.
1555
1552
Error ,
1556
1553
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.
1558
1556
///
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.
1562
1562
///
1563
1563
/// Its `EmissionGuarantee` is `()`.
1564
- Warning ( Option < LintExpectationId > ) ,
1564
+ Warning ,
1565
1565
1566
1566
/// A message giving additional context. Rare, because notes are more commonly attached to other
1567
1567
/// diagnostics such as errors.
@@ -1614,7 +1614,7 @@ impl Level {
1614
1614
Bug | DelayedBug | Fatal | Error => {
1615
1615
spec. set_fg ( Some ( Color :: Red ) ) . set_intense ( true ) ;
1616
1616
}
1617
- Warning ( _) => {
1617
+ ForceWarning ( _) | Warning => {
1618
1618
spec. set_fg ( Some ( Color :: Yellow ) ) . set_intense ( cfg ! ( windows) ) ;
1619
1619
}
1620
1620
Note | OnceNote => {
@@ -1633,7 +1633,7 @@ impl Level {
1633
1633
match self {
1634
1634
Bug | DelayedBug => "error: internal compiler error" ,
1635
1635
Fatal | Error => "error" ,
1636
- Warning ( _) => "warning" ,
1636
+ ForceWarning ( _) | Warning => "warning" ,
1637
1637
Note | OnceNote => "note" ,
1638
1638
Help | OnceHelp => "help" ,
1639
1639
FailureNote => "failure-note" ,
@@ -1647,7 +1647,7 @@ impl Level {
1647
1647
1648
1648
pub fn get_expectation_id ( & self ) -> Option < LintExpectationId > {
1649
1649
match self {
1650
- Expect ( id) | Warning ( Some ( id) ) => Some ( * id) ,
1650
+ Expect ( id) | ForceWarning ( Some ( id) ) => Some ( * id) ,
1651
1651
_ => None ,
1652
1652
}
1653
1653
}
0 commit comments