diff options
| author | Maybe Lapkin <waffle.lapkin@gmail.com> | 2024-11-13 05:14:26 +0100 |
|---|---|---|
| committer | Maybe Lapkin <waffle.lapkin@gmail.com> | 2024-11-14 01:32:54 +0100 |
| commit | 46967bd2e99b8387ccf066c8b9e6323d6dfaaefe (patch) | |
| tree | 6fd2f8904e06caa1c8ae6c58dd64a518f31ed9d5 /compiler | |
| parent | db0740446bed9071b0e0edbd818cc50d40238730 (diff) | |
Mention both release *and* edition breakage for never type lints
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_lint_defs/src/builtin.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_lint_defs/src/lib.rs | 24 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/lint.rs | 6 |
3 files changed, 29 insertions, 5 deletions
diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs index 51146cfd2e9..7f3f31843f5 100644 --- a/compiler/rustc_lint_defs/src/builtin.rs +++ b/compiler/rustc_lint_defs/src/builtin.rs @@ -4185,7 +4185,7 @@ declare_lint! { Warn, "never type fallback affecting unsafe function calls", @future_incompatible = FutureIncompatibleInfo { - reason: FutureIncompatibilityReason::FutureReleaseSemanticsChange, + reason: FutureIncompatibilityReason::EditionAndFutureReleaseError(Edition::Edition2024), reference: "issue #123748 <https://github.com/rust-lang/rust/issues/123748>", }; @edition Edition2024 => Deny; @@ -4239,7 +4239,7 @@ declare_lint! { Warn, "never type fallback affecting unsafe function calls", @future_incompatible = FutureIncompatibleInfo { - reason: FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps, + reason: FutureIncompatibilityReason::EditionAndFutureReleaseError(Edition::Edition2024), reference: "issue #123748 <https://github.com/rust-lang/rust/issues/123748>", }; report_in_external_macro diff --git a/compiler/rustc_lint_defs/src/lib.rs b/compiler/rustc_lint_defs/src/lib.rs index 0caf6ef3a6d..1bf5d9e5098 100644 --- a/compiler/rustc_lint_defs/src/lib.rs +++ b/compiler/rustc_lint_defs/src/lib.rs @@ -381,6 +381,8 @@ pub enum FutureIncompatibilityReason { /// hard errors (and the lint removed). Preferably when there is some /// confidence that the number of impacted projects is very small (few /// should have a broken dependency in their dependency tree). + /// + /// [`EditionAndFutureReleaseError`]: FutureIncompatibilityReason::EditionAndFutureReleaseError FutureReleaseErrorReportInDeps, /// Code that changes meaning in some way in a /// future release. @@ -419,6 +421,17 @@ pub enum FutureIncompatibilityReason { /// slightly changes the text of the diagnostic, but is otherwise the /// same. EditionSemanticsChange(Edition), + /// This will be an error in the provided edition *and* in a future + /// release. + /// + /// This variant a combination of [`FutureReleaseErrorDontReportInDeps`] + /// and [`EditionError`]. This is useful in rare cases when we + /// want to have "preview" of a breaking change in an edition, but do a + /// breaking change later on all editions anyway. + /// + /// [`EditionError`]: FutureIncompatibilityReason::EditionError + /// [`FutureReleaseErrorDontReportInDeps`]: FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps + EditionAndFutureReleaseError(Edition), /// A custom reason. /// /// Choose this variant if the built-in text of the diagnostic of the @@ -431,9 +444,14 @@ pub enum FutureIncompatibilityReason { impl FutureIncompatibilityReason { pub fn edition(self) -> Option<Edition> { match self { - Self::EditionError(e) => Some(e), - Self::EditionSemanticsChange(e) => Some(e), - _ => None, + Self::EditionError(e) + | Self::EditionSemanticsChange(e) + | Self::EditionAndFutureReleaseError(e) => Some(e), + + FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps + | FutureIncompatibilityReason::FutureReleaseErrorReportInDeps + | FutureIncompatibilityReason::FutureReleaseSemanticsChange + | FutureIncompatibilityReason::Custom(_) => None, } } } diff --git a/compiler/rustc_middle/src/lint.rs b/compiler/rustc_middle/src/lint.rs index b5862565e8e..1bcdbe33286 100644 --- a/compiler/rustc_middle/src/lint.rs +++ b/compiler/rustc_middle/src/lint.rs @@ -382,6 +382,12 @@ pub fn lint_level( FutureIncompatibilityReason::EditionSemanticsChange(edition) => { format!("this changes meaning in Rust {edition}") } + FutureIncompatibilityReason::EditionAndFutureReleaseError(edition) => { + format!( + "this was previously accepted by the compiler but is being phased out; \ + it will become a hard error in Rust {edition} and in a future release in all editions!" + ) + } FutureIncompatibilityReason::Custom(reason) => reason.to_owned(), }; |
