Skip to content

Commit

Permalink
Rollup merge of #116049 - RalfJung:future-incompat, r=Nilstrieb
Browse files Browse the repository at this point in the history
give FutureIncompatibilityReason variants more explicit names

Also make the `reason` field mandatory when declaring a lint, to make sure this is a deliberate decision.
  • Loading branch information
matthiaskrgr authored Sep 22, 2023
2 parents 66f272d + 7abbb9a commit 1a18ec0
Show file tree
Hide file tree
Showing 9 changed files with 79 additions and 32 deletions.
8 changes: 7 additions & 1 deletion compiler/rustc_errors/src/diagnostic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_lint/src/array_into_iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ declare_lint! {
Warn,
"detects calling `into_iter` on arrays in Rust 2015 and 2018",
@future_incompatible = FutureIncompatibleInfo {
reference: "<https://doc.rust-lang.org/nightly/edition-guide/rust-2021/IntoIterator-for-arrays.html>",
reason: FutureIncompatibilityReason::EditionSemanticsChange(Edition::Edition2021),
reference: "<https://doc.rust-lang.org/nightly/edition-guide/rust-2021/IntoIterator-for-arrays.html>",
};
}

Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_lint/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -844,8 +844,8 @@ declare_lint! {
Warn,
"detects anonymous parameters",
@future_incompatible = FutureIncompatibleInfo {
reference: "issue #41686 <https://github.com/rust-lang/rust/issues/41686>",
reason: FutureIncompatibilityReason::EditionError(Edition::Edition2018),
reference: "issue #41686 <https://github.com/rust-lang/rust/issues/41686>",
};
}

Expand Down Expand Up @@ -1669,8 +1669,8 @@ declare_lint! {
Warn,
"`...` range patterns are deprecated",
@future_incompatible = FutureIncompatibleInfo {
reference: "<https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>",
reason: FutureIncompatibilityReason::EditionError(Edition::Edition2021),
reference: "<https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>",
};
}

Expand Down Expand Up @@ -1804,8 +1804,8 @@ declare_lint! {
Allow,
"detects edition keywords being used as an identifier",
@future_incompatible = FutureIncompatibleInfo {
reference: "issue #49716 <https://github.com/rust-lang/rust/issues/49716>",
reason: FutureIncompatibilityReason::EditionError(Edition::Edition2018),
reference: "issue #49716 <https://github.com/rust-lang/rust/issues/49716>",
};
}

Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_lint/src/deref_into_dyn_supertrait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use crate::{

use rustc_hir as hir;
use rustc_middle::{traits::util::supertraits, ty};
use rustc_session::lint::FutureIncompatibilityReason;
use rustc_span::sym;

declare_lint! {
Expand Down Expand Up @@ -48,6 +49,7 @@ declare_lint! {
Warn,
"`Deref` implementation usage with a supertrait trait object for output might be shadowed in the future",
@future_incompatible = FutureIncompatibleInfo {
reason: FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps,
reference: "issue #89460 <https://github.com/rust-lang/rust/issues/89460>",
};
}
Expand Down
Loading

0 comments on commit 1a18ec0

Please sign in to comment.