summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_lint_defs/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--compiler/rustc_lint_defs/src/builtin.rs37
-rw-r--r--compiler/rustc_lint_defs/src/lib.rs34
2 files changed, 32 insertions, 39 deletions
diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs
index e5dfda24d..61ee467f5 100644
--- a/compiler/rustc_lint_defs/src/builtin.rs
+++ b/compiler/rustc_lint_defs/src/builtin.rs
@@ -264,37 +264,6 @@ declare_lint! {
}
declare_lint! {
- /// The `const_err` lint detects an erroneous expression while doing
- /// constant evaluation.
- ///
- /// ### Example
- ///
- /// ```rust,compile_fail
- /// #![allow(unconditional_panic)]
- /// const C: i32 = 1/0;
- /// ```
- ///
- /// {{produces}}
- ///
- /// ### Explanation
- ///
- /// This lint detects constants that fail to evaluate. Allowing the lint will accept the
- /// constant declaration, but any use of this constant will still lead to a hard error. This is
- /// a future incompatibility lint; the plan is to eventually entirely forbid even declaring
- /// constants that cannot be evaluated. See [issue #71800] for more details.
- ///
- /// [issue #71800]: https://github.com/rust-lang/rust/issues/71800
- pub CONST_ERR,
- Deny,
- "constant evaluation encountered erroneous expression",
- @future_incompatible = FutureIncompatibleInfo {
- reference: "issue #71800 <https://github.com/rust-lang/rust/issues/71800>",
- reason: FutureIncompatibilityReason::FutureReleaseErrorReportNow,
- };
- report_in_external_macro
-}
-
-declare_lint! {
/// The `unused_imports` lint detects imports that are never used.
///
/// ### Example
@@ -1458,6 +1427,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,
};
}
@@ -2909,7 +2879,7 @@ declare_lint! {
/// ### Example
///
/// ```rust
- /// #![feature(naked_functions)]
+ /// #![feature(asm_experimental_arch, naked_functions)]
///
/// use std::arch::asm;
///
@@ -3295,7 +3265,6 @@ declare_lint_pass! {
EXPORTED_PRIVATE_DEPENDENCIES,
PUB_USE_OF_PRIVATE_EXTERN_CRATE,
INVALID_TYPE_PARAM_DEFAULT,
- CONST_ERR,
RENAMED_AND_REMOVED_LINTS,
UNALIGNED_REFERENCES,
CONST_ITEM_MUTATION,
@@ -3969,7 +3938,7 @@ declare_lint! {
///
/// The compiler disables the automatic implementation if an explicit one
/// exists for given type constructor. The exact rules governing this
- /// are currently unsound and quite subtle and and will be modified in the future.
+ /// are currently unsound, quite subtle, and will be modified in the future.
/// This change will cause the automatic implementation to be disabled in more
/// cases, potentially breaking some code.
pub SUSPICIOUS_AUTO_TRAIT_IMPLS,
diff --git a/compiler/rustc_lint_defs/src/lib.rs b/compiler/rustc_lint_defs/src/lib.rs
index 11b2d057a..aa54b3d8a 100644
--- a/compiler/rustc_lint_defs/src/lib.rs
+++ b/compiler/rustc_lint_defs/src/lib.rs
@@ -25,6 +25,9 @@ macro_rules! pluralize {
($x:expr) => {
if $x != 1 { "s" } else { "" }
};
+ ("has", $x:expr) => {
+ if $x == 1 { "has" } else { "have" }
+ };
("is", $x:expr) => {
if $x == 1 { "is" } else { "are" }
};
@@ -92,7 +95,7 @@ pub enum LintExpectationId {
/// stable and can be cached. The additional index ensures that nodes with
/// several expectations can correctly match diagnostics to the individual
/// expectation.
- Stable { hir_id: HirId, attr_index: u16, lint_index: Option<u16> },
+ Stable { hir_id: HirId, attr_index: u16, lint_index: Option<u16>, attr_id: Option<AttrId> },
}
impl LintExpectationId {
@@ -116,13 +119,31 @@ impl LintExpectationId {
*lint_index = new_lint_index
}
+
+ /// Prepares the id for hashing. Removes references to the ast.
+ /// Should only be called when the id is stable.
+ pub fn normalize(self) -> Self {
+ match self {
+ Self::Stable { hir_id, attr_index, lint_index, .. } => {
+ Self::Stable { hir_id, attr_index, lint_index, attr_id: None }
+ }
+ Self::Unstable { .. } => {
+ unreachable!("`normalize` called when `ExpectationId` is unstable")
+ }
+ }
+ }
}
impl<HCX: rustc_hir::HashStableContext> HashStable<HCX> for LintExpectationId {
#[inline]
fn hash_stable(&self, hcx: &mut HCX, hasher: &mut StableHasher) {
match self {
- LintExpectationId::Stable { hir_id, attr_index, lint_index: Some(lint_index) } => {
+ LintExpectationId::Stable {
+ hir_id,
+ attr_index,
+ lint_index: Some(lint_index),
+ attr_id: _,
+ } => {
hir_id.hash_stable(hcx, hasher);
attr_index.hash_stable(hcx, hasher);
lint_index.hash_stable(hcx, hasher);
@@ -142,9 +163,12 @@ impl<HCX: rustc_hir::HashStableContext> ToStableHashKey<HCX> for LintExpectation
#[inline]
fn to_stable_hash_key(&self, _: &HCX) -> Self::KeyType {
match self {
- LintExpectationId::Stable { hir_id, attr_index, lint_index: Some(lint_index) } => {
- (*hir_id, *attr_index, *lint_index)
- }
+ LintExpectationId::Stable {
+ hir_id,
+ attr_index,
+ lint_index: Some(lint_index),
+ attr_id: _,
+ } => (*hir_id, *attr_index, *lint_index),
_ => {
unreachable!("HashStable should only be called for a filled `LintExpectationId`")
}