diff options
| author | Ralf Jung <post@ralfj.de> | 2023-09-22 08:25:11 +0200 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2023-09-22 08:51:18 +0200 |
| commit | e888d470e91ee4e027871d850766802a6b6dad86 (patch) | |
| tree | 020ac7c9a6b6f7d41d9c5e85274dcaa8ef6001bd | |
| parent | b7573187180a6ad13ba557f85b7e19a51f8fdaf1 (diff) | |
| download | rust-e888d470e91ee4e027871d850766802a6b6dad86.tar.gz rust-e888d470e91ee4e027871d850766802a6b6dad86.zip | |
give FutureIncompatibilityReason variants more explicit names
| -rw-r--r-- | compiler/rustc_errors/src/diagnostic.rs | 8 | ||||
| -rw-r--r-- | compiler/rustc_lint_defs/src/builtin.rs | 20 | ||||
| -rw-r--r-- | compiler/rustc_lint_defs/src/lib.rs | 16 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/lint.rs | 9 |
4 files changed, 34 insertions, 19 deletions
diff --git a/compiler/rustc_errors/src/diagnostic.rs b/compiler/rustc_errors/src/diagnostic.rs index 3fd087b1d5e..470f318eb33 100644 --- a/compiler/rustc_errors/src/diagnostic.rs +++ b/compiler/rustc_errors/src/diagnostic.rs @@ -151,7 +151,12 @@ impl fmt::Display for DiagnosticLocation { #[derive(Clone, Debug, PartialEq, Eq, Hash, Encodable, Decodable)] pub enum DiagnosticId { Error(String), - Lint { name: String, has_future_breakage: bool, is_force_warn: bool }, + Lint { + name: String, + /// Indicates whether this lint should show up in cargo's future breakage report. + has_future_breakage: bool, + is_force_warn: bool, + }, } /// A "sub"-diagnostic attached to a parent diagnostic. @@ -301,6 +306,7 @@ impl Diagnostic { } } + /// Indicates whether this diagnostic should show up in cargo's future breakage report. pub fn has_future_breakage(&self) -> bool { match self.code { Some(DiagnosticId::Lint { has_future_breakage, .. }) => has_future_breakage, diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs index 860366fdd61..f71d49572d3 100644 --- a/compiler/rustc_lint_defs/src/builtin.rs +++ b/compiler/rustc_lint_defs/src/builtin.rs @@ -1017,7 +1017,7 @@ declare_lint! { "raw pointers must be aligned before dereferencing", @future_incompatible = FutureIncompatibleInfo { reference: "issue #68585 <https://github.com/rust-lang/rust/issues/104616>", - reason: FutureIncompatibilityReason::FutureReleaseErrorReportNow, + reason: FutureIncompatibilityReason::FutureReleaseErrorReportInDeps, }; } @@ -1387,7 +1387,7 @@ declare_lint! { "trait-object types were treated as different depending on marker-trait order", @future_incompatible = FutureIncompatibleInfo { reference: "issue #56484 <https://github.com/rust-lang/rust/issues/56484>", - reason: FutureIncompatibilityReason::FutureReleaseErrorReportNow, + reason: FutureIncompatibilityReason::FutureReleaseErrorReportInDeps, }; } @@ -2006,7 +2006,7 @@ declare_lint! { "detects proc macro derives using inaccessible names from parent modules", @future_incompatible = FutureIncompatibleInfo { reference: "issue #83583 <https://github.com/rust-lang/rust/issues/83583>", - reason: FutureIncompatibilityReason::FutureReleaseErrorReportNow, + reason: FutureIncompatibilityReason::FutureReleaseErrorReportInDeps, }; } @@ -2618,7 +2618,7 @@ declare_lint! { "a C-like enum implementing Drop is cast", @future_incompatible = FutureIncompatibleInfo { reference: "issue #73333 <https://github.com/rust-lang/rust/issues/73333>", - reason: FutureIncompatibilityReason::FutureReleaseErrorReportNow, + reason: FutureIncompatibilityReason::FutureReleaseErrorReportInDeps, }; } @@ -2976,7 +2976,7 @@ declare_lint! { "trailing semicolon in macro body used as expression", @future_incompatible = FutureIncompatibleInfo { reference: "issue #79813 <https://github.com/rust-lang/rust/issues/79813>", - reason: FutureIncompatibilityReason::FutureReleaseErrorReportNow, + reason: FutureIncompatibilityReason::FutureReleaseErrorReportInDeps, }; } @@ -3709,7 +3709,7 @@ declare_lint! { "detects usage of old versions of certain proc-macro crates", @future_incompatible = FutureIncompatibleInfo { reference: "issue #83125 <https://github.com/rust-lang/rust/issues/83125>", - reason: FutureIncompatibilityReason::FutureReleaseErrorReportNow, + reason: FutureIncompatibilityReason::FutureReleaseErrorReportInDeps, }; } @@ -4222,7 +4222,7 @@ declare_lint! { "impl method assumes more implied bounds than its corresponding trait method", @future_incompatible = FutureIncompatibleInfo { reference: "issue #105572 <https://github.com/rust-lang/rust/issues/105572>", - reason: FutureIncompatibilityReason::FutureReleaseErrorReportNow, + reason: FutureIncompatibilityReason::FutureReleaseErrorReportInDeps, }; } @@ -4254,7 +4254,7 @@ declare_lint! { "`[u8]` or `str` used in a packed struct with `derive`", @future_incompatible = FutureIncompatibleInfo { reference: "issue #107457 <https://github.com/rust-lang/rust/issues/107457>", - reason: FutureIncompatibilityReason::FutureReleaseErrorReportNow, + reason: FutureIncompatibilityReason::FutureReleaseErrorReportInDeps, }; report_in_external_macro } @@ -4483,7 +4483,7 @@ declare_lint! { Warn, "detects certain glob imports that require reporting an ambiguity error", @future_incompatible = FutureIncompatibleInfo { - reason: FutureIncompatibilityReason::FutureReleaseError, + reason: FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps, reference: "issue #114095 <https://github.com/rust-lang/rust/issues/114095>", }; } @@ -4568,7 +4568,7 @@ declare_lint! { Warn, "elided lifetimes cannot be used in associated constants in impls", @future_incompatible = FutureIncompatibleInfo { - reason: FutureIncompatibilityReason::FutureReleaseError, + reason: FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps, reference: "issue #115010 <https://github.com/rust-lang/rust/issues/115010>", }; } diff --git a/compiler/rustc_lint_defs/src/lib.rs b/compiler/rustc_lint_defs/src/lib.rs index ef2f7940477..aced50ca510 100644 --- a/compiler/rustc_lint_defs/src/lib.rs +++ b/compiler/rustc_lint_defs/src/lib.rs @@ -347,12 +347,18 @@ pub struct FutureIncompatibleInfo { /// The reason for future incompatibility #[derive(Copy, Clone, Debug)] pub enum FutureIncompatibilityReason { - /// This will be an error in a future release - /// for all editions - FutureReleaseError, + /// This will be an error in a future release for all editions + /// + /// This will *not* show up in cargo's future breakage report. + /// The warning will hence only be seen in local crates, not in dependencies. + FutureReleaseErrorDontReportInDeps, /// This will be an error in a future release, and /// Cargo should create a report even for dependencies - FutureReleaseErrorReportNow, + /// + /// This is the *only* reason that will make future incompatibility warnings show up in cargo's + /// reports. All other future incompatibility warnings are not visible when they occur in a + /// dependency. + FutureReleaseErrorReportInDeps, /// Code that changes meaning in some way in a /// future release. FutureReleaseSemanticsChange, @@ -380,7 +386,7 @@ impl FutureIncompatibleInfo { pub const fn default_fields_for_macro() -> Self { FutureIncompatibleInfo { reference: "", - reason: FutureIncompatibilityReason::FutureReleaseError, + reason: FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps, explain_reason: true, } } diff --git a/compiler/rustc_middle/src/lint.rs b/compiler/rustc_middle/src/lint.rs index 037f84f476f..59849e8eb40 100644 --- a/compiler/rustc_middle/src/lint.rs +++ b/compiler/rustc_middle/src/lint.rs @@ -314,7 +314,10 @@ pub fn struct_lint_level( // Default allow lints trigger too often for testing. sess.opts.unstable_opts.future_incompat_test && lint.default_level != Level::Allow, |incompat| { - matches!(incompat.reason, FutureIncompatibilityReason::FutureReleaseErrorReportNow) + matches!( + incompat.reason, + FutureIncompatibilityReason::FutureReleaseErrorReportInDeps + ) }, ); @@ -404,8 +407,8 @@ pub fn struct_lint_level( if let Some(future_incompatible) = future_incompatible { let explanation = match future_incompatible.reason { - FutureIncompatibilityReason::FutureReleaseError - | FutureIncompatibilityReason::FutureReleaseErrorReportNow => { + FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps + | FutureIncompatibilityReason::FutureReleaseErrorReportInDeps => { "this was previously accepted by the compiler but is being phased out; \ it will become a hard error in a future release!" .to_owned() |
