@@ -905,8 +905,8 @@ impl<'a> DiagCtxtHandle<'a> {
905905 DelayedBug => {
906906 return self . inner . borrow_mut ( ) . emit_diagnostic ( diag, self . tainted_with_errors ) ;
907907 }
908- ForceWarning ( _ ) | Warning | Note | OnceNote | Help | OnceHelp | FailureNote | Allow
909- | Expect ( _ ) => None ,
908+ ForceWarning | Warning | Note | OnceNote | Help | OnceHelp | FailureNote | Allow
909+ | Expect => None ,
910910 } ;
911911
912912 // FIXME(Centril, #69537): Consider reintroducing panic on overwriting a stashed diagnostic
@@ -1045,7 +1045,7 @@ impl<'a> DiagCtxtHandle<'a> {
10451045 // Use `ForceWarning` rather than `Warning` to guarantee emission, e.g. with a
10461046 // configuration like `--cap-lints allow --force-warn bare_trait_objects`.
10471047 inner. emit_diagnostic (
1048- DiagInner :: new ( ForceWarning ( None ) , DiagMessage :: Str ( warnings) ) ,
1048+ DiagInner :: new ( ForceWarning , DiagMessage :: Str ( warnings) ) ,
10491049 None ,
10501050 ) ;
10511051 }
@@ -1450,7 +1450,7 @@ impl<'a> DiagCtxtHandle<'a> {
14501450 #[ rustc_lint_diagnostics]
14511451 #[ track_caller]
14521452 pub fn struct_expect ( self , msg : impl Into < DiagMessage > , id : LintExpectationId ) -> Diag < ' a , ( ) > {
1453- Diag :: new ( self , Expect ( id ) , msg)
1453+ Diag :: new ( self , Expect , msg) . with_lint_id ( id )
14541454 }
14551455}
14561456
@@ -1510,7 +1510,7 @@ impl DiagCtxtInner {
15101510 // Future breakages aren't emitted if they're `Level::Allow` or
15111511 // `Level::Expect`, but they still need to be constructed and
15121512 // stashed below, so they'll trigger the must_produce_diag check.
1513- assert_matches ! ( diagnostic. level, Error | Warning | Allow | Expect ( _ ) ) ;
1513+ assert_matches ! ( diagnostic. level, Error | Warning | Allow | Expect ) ;
15141514 self . future_breakage_diagnostics . push ( diagnostic. clone ( ) ) ;
15151515 }
15161516
@@ -1558,7 +1558,7 @@ impl DiagCtxtInner {
15581558 } ;
15591559 }
15601560 }
1561- ForceWarning ( None ) => { } // `ForceWarning(Some(...))` is below, with `Expect`
1561+ ForceWarning if diagnostic . lint_id . is_none ( ) => { } // `ForceWarning(Some(...))` is below, with `Expect`
15621562 Warning => {
15631563 if !self . flags . can_emit_warnings {
15641564 // We are not emitting warnings.
@@ -1580,9 +1580,9 @@ impl DiagCtxtInner {
15801580 }
15811581 return None ;
15821582 }
1583- Expect ( expect_id ) | ForceWarning ( Some ( expect_id ) ) => {
1584- self . fulfilled_expectations . insert ( expect_id ) ;
1585- if let Expect ( _ ) = diagnostic. level {
1583+ Expect | ForceWarning => {
1584+ self . fulfilled_expectations . insert ( diagnostic . lint_id . unwrap ( ) ) ;
1585+ if let Expect = diagnostic. level {
15861586 // Nothing emitted here for expected lints.
15871587 TRACK_DIAGNOSTIC ( diagnostic, & mut |_| None ) ;
15881588 self . suppressed_expected_diag = true ;
@@ -1631,7 +1631,7 @@ impl DiagCtxtInner {
16311631
16321632 if is_error {
16331633 self . deduplicated_err_count += 1 ;
1634- } else if matches ! ( diagnostic. level, ForceWarning ( _ ) | Warning ) {
1634+ } else if matches ! ( diagnostic. level, ForceWarning | Warning ) {
16351635 self . deduplicated_warn_count += 1 ;
16361636 }
16371637 self . has_printed = true ;
@@ -1899,9 +1899,9 @@ pub enum Level {
18991899 /// A `force-warn` lint warning about the code being compiled. Does not prevent compilation
19001900 /// from finishing.
19011901 ///
1902- /// The [`LintExpectationId`] is used for expected lint diagnostics. In all other cases this
1902+ /// Requires a [`LintExpectationId`] for expected lint diagnostics. In all other cases this
19031903 /// should be `None`.
1904- ForceWarning ( Option < LintExpectationId > ) ,
1904+ ForceWarning ,
19051905
19061906 /// A warning about the code being compiled. Does not prevent compilation from finishing.
19071907 /// Will be skipped if `can_emit_warnings` is false.
@@ -1926,8 +1926,8 @@ pub enum Level {
19261926 /// Only used for lints.
19271927 Allow ,
19281928
1929- /// Only used for lints.
1930- Expect ( LintExpectationId ) ,
1929+ /// Only used for lints. Requires a [`LintExpectationId`] for silencing the lints.
1930+ Expect ,
19311931}
19321932
19331933impl fmt:: Display for Level {
@@ -1943,7 +1943,7 @@ impl Level {
19431943 Bug | Fatal | Error | DelayedBug => {
19441944 spec. set_fg ( Some ( Color :: Red ) ) . set_intense ( true ) ;
19451945 }
1946- ForceWarning ( _ ) | Warning => {
1946+ ForceWarning | Warning => {
19471947 spec. set_fg ( Some ( Color :: Yellow ) ) . set_intense ( cfg ! ( windows) ) ;
19481948 }
19491949 Note | OnceNote => {
@@ -1953,7 +1953,7 @@ impl Level {
19531953 spec. set_fg ( Some ( Color :: Cyan ) ) . set_intense ( true ) ;
19541954 }
19551955 FailureNote => { }
1956- Allow | Expect ( _ ) => unreachable ! ( ) ,
1956+ Allow | Expect => unreachable ! ( ) ,
19571957 }
19581958 spec
19591959 }
@@ -1962,11 +1962,11 @@ impl Level {
19621962 match self {
19631963 Bug | DelayedBug => "error: internal compiler error" ,
19641964 Fatal | Error => "error" ,
1965- ForceWarning ( _ ) | Warning => "warning" ,
1965+ ForceWarning | Warning => "warning" ,
19661966 Note | OnceNote => "note" ,
19671967 Help | OnceHelp => "help" ,
19681968 FailureNote => "failure-note" ,
1969- Allow | Expect ( _ ) => unreachable ! ( ) ,
1969+ Allow | Expect => unreachable ! ( ) ,
19701970 }
19711971 }
19721972
@@ -1977,8 +1977,7 @@ impl Level {
19771977 // Can this level be used in a subdiagnostic message?
19781978 fn can_be_subdiag ( & self ) -> bool {
19791979 match self {
1980- Bug | DelayedBug | Fatal | Error | ForceWarning ( _) | FailureNote | Allow
1981- | Expect ( _) => false ,
1980+ Bug | DelayedBug | Fatal | Error | ForceWarning | FailureNote | Allow | Expect => false ,
19821981
19831982 Warning | Note | Help | OnceNote | OnceHelp => true ,
19841983 }
0 commit comments