summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_lint_defs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 18:31:44 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 18:31:44 +0000
commitc23a457e72abe608715ac76f076f47dc42af07a5 (patch)
tree2772049aaf84b5c9d0ed12ec8d86812f7a7904b6 /compiler/rustc_lint_defs
parentReleasing progress-linux version 1.73.0+dfsg1-1~progress7.99u1. (diff)
downloadrustc-c23a457e72abe608715ac76f076f47dc42af07a5.tar.xz
rustc-c23a457e72abe608715ac76f076f47dc42af07a5.zip
Merging upstream version 1.74.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'compiler/rustc_lint_defs')
-rw-r--r--compiler/rustc_lint_defs/src/builtin.rs264
-rw-r--r--compiler/rustc_lint_defs/src/lib.rs62
2 files changed, 222 insertions, 104 deletions
diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs
index 96c31a90d..69b462d32 100644
--- a/compiler/rustc_lint_defs/src/builtin.rs
+++ b/compiler/rustc_lint_defs/src/builtin.rs
@@ -39,6 +39,7 @@ declare_lint! {
Warn,
"applying forbid to lint-groups",
@future_incompatible = FutureIncompatibleInfo {
+ reason: FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps,
reference: "issue #81670 <https://github.com/rust-lang/rust/issues/81670>",
};
}
@@ -74,6 +75,7 @@ declare_lint! {
Deny,
"ill-formed attribute inputs that were previously accepted and used in practice",
@future_incompatible = FutureIncompatibleInfo {
+ reason: FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps,
reference: "issue #57571 <https://github.com/rust-lang/rust/issues/57571>",
};
crate_level_only
@@ -110,6 +112,7 @@ declare_lint! {
Deny,
"conflicts between `#[repr(..)]` hints that were previously accepted and used in practice",
@future_incompatible = FutureIncompatibleInfo {
+ reason: FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps,
reference: "issue #68585 <https://github.com/rust-lang/rust/issues/68585>",
};
}
@@ -303,6 +306,7 @@ declare_lint! {
/// pub async fn uhoh() {
/// let guard = SyncThing {};
/// yield_now().await;
+ /// let _guard = guard;
/// }
/// ```
///
@@ -983,44 +987,6 @@ declare_lint! {
}
declare_lint! {
- /// The `private_in_public` lint detects private items in public
- /// interfaces not caught by the old implementation.
- ///
- /// ### Example
- ///
- /// ```rust
- /// # #![allow(unused)]
- /// struct SemiPriv;
- ///
- /// mod m1 {
- /// struct Priv;
- /// impl super::SemiPriv {
- /// pub fn f(_: Priv) {}
- /// }
- /// }
- /// # fn main() {}
- /// ```
- ///
- /// {{produces}}
- ///
- /// ### Explanation
- ///
- /// The visibility rules are intended to prevent exposing private items in
- /// public interfaces. This is a [future-incompatible] lint to transition
- /// this to a hard error in the future. See [issue #34537] for more
- /// details.
- ///
- /// [issue #34537]: https://github.com/rust-lang/rust/issues/34537
- /// [future-incompatible]: ../index.md#future-incompatible-lints
- pub PRIVATE_IN_PUBLIC,
- Warn,
- "detect private items in public interfaces not caught by the old implementation",
- @future_incompatible = FutureIncompatibleInfo {
- reference: "issue #34537 <https://github.com/rust-lang/rust/issues/34537>",
- };
-}
-
-declare_lint! {
/// The `invalid_alignment` lint detects dereferences of misaligned pointers during
/// constant evaluation.
///
@@ -1054,8 +1020,8 @@ declare_lint! {
Deny,
"raw pointers must be aligned before dereferencing",
@future_incompatible = FutureIncompatibleInfo {
+ reason: FutureIncompatibilityReason::FutureReleaseErrorReportInDeps,
reference: "issue #68585 <https://github.com/rust-lang/rust/issues/104616>",
- reason: FutureIncompatibilityReason::FutureReleaseErrorReportNow,
};
}
@@ -1134,6 +1100,7 @@ declare_lint! {
Deny,
"detect public re-exports of private extern crates",
@future_incompatible = FutureIncompatibleInfo {
+ reason: FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps,
reference: "issue #34537 <https://github.com/rust-lang/rust/issues/34537>",
};
}
@@ -1163,6 +1130,7 @@ declare_lint! {
Deny,
"type parameter default erroneously allowed in invalid location",
@future_incompatible = FutureIncompatibleInfo {
+ reason: FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps,
reference: "issue #36887 <https://github.com/rust-lang/rust/issues/36887>",
};
}
@@ -1305,6 +1273,7 @@ declare_lint! {
Deny,
"patterns in functions without body were erroneously allowed",
@future_incompatible = FutureIncompatibleInfo {
+ reason: FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps,
reference: "issue #35203 <https://github.com/rust-lang/rust/issues/35203>",
};
}
@@ -1348,6 +1317,7 @@ declare_lint! {
Deny,
"detects missing fragment specifiers in unused `macro_rules!` patterns",
@future_incompatible = FutureIncompatibleInfo {
+ reason: FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps,
reference: "issue #40107 <https://github.com/rust-lang/rust/issues/40107>",
};
}
@@ -1389,6 +1359,7 @@ declare_lint! {
Warn,
"detects generic lifetime arguments in path segments with late bound lifetime parameters",
@future_incompatible = FutureIncompatibleInfo {
+ reason: FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps,
reference: "issue #42868 <https://github.com/rust-lang/rust/issues/42868>",
};
}
@@ -1424,8 +1395,8 @@ declare_lint! {
Deny,
"trait-object types were treated as different depending on marker-trait order",
@future_incompatible = FutureIncompatibleInfo {
+ reason: FutureIncompatibilityReason::FutureReleaseErrorReportInDeps,
reference: "issue #56484 <https://github.com/rust-lang/rust/issues/56484>",
- reason: FutureIncompatibilityReason::FutureReleaseErrorReportNow,
};
}
@@ -1464,6 +1435,7 @@ declare_lint! {
Warn,
"distinct impls distinguished only by the leak-check code",
@future_incompatible = FutureIncompatibleInfo {
+ reason: FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps,
reference: "issue #56105 <https://github.com/rust-lang/rust/issues/56105>",
};
}
@@ -1655,8 +1627,8 @@ declare_lint! {
Warn,
"raw pointer to an inference variable",
@future_incompatible = FutureIncompatibleInfo {
- reference: "issue #46906 <https://github.com/rust-lang/rust/issues/46906>",
reason: FutureIncompatibilityReason::EditionError(Edition::Edition2018),
+ reference: "issue #46906 <https://github.com/rust-lang/rust/issues/46906>",
};
}
@@ -1723,8 +1695,8 @@ declare_lint! {
Warn,
"suggest using `dyn Trait` for trait objects",
@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>",
};
}
@@ -1778,8 +1750,8 @@ declare_lint! {
"fully qualified paths that start with a module name \
instead of `crate`, `self`, or an extern crate name",
@future_incompatible = FutureIncompatibleInfo {
- reference: "issue #53130 <https://github.com/rust-lang/rust/issues/53130>",
reason: FutureIncompatibilityReason::EditionError(Edition::Edition2018),
+ reference: "issue #53130 <https://github.com/rust-lang/rust/issues/53130>",
};
}
@@ -1827,6 +1799,7 @@ declare_lint! {
Warn,
"floating-point literals cannot be used in patterns",
@future_incompatible = FutureIncompatibleInfo {
+ reason: FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps,
reference: "issue #41620 <https://github.com/rust-lang/rust/issues/41620>",
};
}
@@ -1977,6 +1950,7 @@ declare_lint! {
Warn,
"checks the object safety of where clauses",
@future_incompatible = FutureIncompatibleInfo {
+ reason: FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps,
reference: "issue #51443 <https://github.com/rust-lang/rust/issues/51443>",
};
}
@@ -2043,8 +2017,8 @@ declare_lint! {
Deny,
"detects proc macro derives using inaccessible names from parent modules",
@future_incompatible = FutureIncompatibleInfo {
+ reason: FutureIncompatibilityReason::FutureReleaseErrorReportInDeps,
reference: "issue #83583 <https://github.com/rust-lang/rust/issues/83583>",
- reason: FutureIncompatibilityReason::FutureReleaseErrorReportNow,
};
}
@@ -2146,6 +2120,7 @@ declare_lint! {
"macro-expanded `macro_export` macros from the current crate \
cannot be referred to by absolute paths",
@future_incompatible = FutureIncompatibleInfo {
+ reason: FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps,
reference: "issue #52234 <https://github.com/rust-lang/rust/issues/52234>",
};
crate_level_only
@@ -2237,6 +2212,7 @@ declare_lint! {
Warn,
"constant used in pattern contains value of non-structural-match type in a field or a variant",
@future_incompatible = FutureIncompatibleInfo {
+ reason: FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps,
reference: "issue #62411 <https://github.com/rust-lang/rust/issues/62411>",
};
}
@@ -2291,6 +2267,7 @@ declare_lint! {
Allow,
"pointers are not structural-match",
@future_incompatible = FutureIncompatibleInfo {
+ reason: FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps,
reference: "issue #62411 <https://github.com/rust-lang/rust/issues/70861>",
};
}
@@ -2329,11 +2306,63 @@ declare_lint! {
"constant used in pattern of non-structural-match type and the constant's initializer \
expression contains values of non-structural-match types",
@future_incompatible = FutureIncompatibleInfo {
+ reason: FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps,
reference: "issue #73448 <https://github.com/rust-lang/rust/issues/73448>",
};
}
declare_lint! {
+ /// The `const_patterns_without_partial_eq` lint detects constants that are used in patterns,
+ /// whose type does not implement `PartialEq`.
+ ///
+ /// ### Example
+ ///
+ /// ```rust,compile_fail
+ /// #![deny(const_patterns_without_partial_eq)]
+ ///
+ /// trait EnumSetType {
+ /// type Repr;
+ /// }
+ ///
+ /// enum Enum8 { }
+ /// impl EnumSetType for Enum8 {
+ /// type Repr = u8;
+ /// }
+ ///
+ /// #[derive(PartialEq, Eq)]
+ /// struct EnumSet<T: EnumSetType> {
+ /// __enumset_underlying: T::Repr,
+ /// }
+ ///
+ /// const CONST_SET: EnumSet<Enum8> = EnumSet { __enumset_underlying: 3 };
+ ///
+ /// fn main() {
+ /// match CONST_SET {
+ /// CONST_SET => { /* ok */ }
+ /// _ => panic!("match fell through?"),
+ /// }
+ /// }
+ /// ```
+ ///
+ /// {{produces}}
+ ///
+ /// ### Explanation
+ ///
+ /// Previous versions of Rust accepted constants in patterns, even if those constants' types
+ /// did not have `PartialEq` implemented. The compiler falls back to comparing the value
+ /// field-by-field. In the future we'd like to ensure that pattern matching always
+ /// follows `PartialEq` semantics, so that trait bound will become a requirement for
+ /// matching on constants.
+ pub CONST_PATTERNS_WITHOUT_PARTIAL_EQ,
+ Warn,
+ "constant in pattern does not implement `PartialEq`",
+ @future_incompatible = FutureIncompatibleInfo {
+ reason: FutureIncompatibilityReason::FutureReleaseErrorReportInDeps,
+ reference: "issue #116122 <https://github.com/rust-lang/rust/issues/116122>",
+ };
+}
+
+declare_lint! {
/// The `ambiguous_associated_items` lint detects ambiguity between
/// [associated items] and [enum variants].
///
@@ -2386,6 +2415,7 @@ declare_lint! {
Deny,
"ambiguous associated items",
@future_incompatible = FutureIncompatibleInfo {
+ reason: FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps,
reference: "issue #57644 <https://github.com/rust-lang/rust/issues/57644>",
};
}
@@ -2427,6 +2457,7 @@ declare_lint! {
Deny,
"a feature gate that doesn't break dependent crates",
@future_incompatible = FutureIncompatibleInfo {
+ reason: FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps,
reference: "issue #64266 <https://github.com/rust-lang/rust/issues/64266>",
};
}
@@ -2592,8 +2623,8 @@ declare_lint! {
///
/// The fix to this is to wrap the unsafe code in an `unsafe` block.
///
- /// This lint is "allow" by default since this will affect a large amount
- /// of existing code, and the exact plan for increasing the severity is
+ /// This lint is "allow" by default on editions up to 2021, from 2024 it is
+ /// "warn" by default; the plan for increasing severity further is
/// still being considered. See [RFC #2585] and [issue #71668] for more
/// details.
///
@@ -2605,6 +2636,7 @@ declare_lint! {
pub UNSAFE_OP_IN_UNSAFE_FN,
Allow,
"unsafe operations in unsafe functions without an explicit unsafe block are deprecated",
+ @edition Edition2024 => Warn;
}
declare_lint! {
@@ -2654,8 +2686,8 @@ declare_lint! {
Deny,
"a C-like enum implementing Drop is cast",
@future_incompatible = FutureIncompatibleInfo {
+ reason: FutureIncompatibilityReason::FutureReleaseErrorReportInDeps,
reference: "issue #73333 <https://github.com/rust-lang/rust/issues/73333>",
- reason: FutureIncompatibilityReason::FutureReleaseErrorReportNow,
};
}
@@ -2784,6 +2816,7 @@ declare_lint! {
Warn,
"detects a generic constant is used in a type without a emitting a warning",
@future_incompatible = FutureIncompatibleInfo {
+ reason: FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps,
reference: "issue #76200 <https://github.com/rust-lang/rust/issues/76200>",
};
}
@@ -2842,6 +2875,7 @@ declare_lint! {
Warn,
"uninhabited static",
@future_incompatible = FutureIncompatibleInfo {
+ reason: FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps,
reference: "issue #74840 <https://github.com/rust-lang/rust/issues/74840>",
};
}
@@ -3012,8 +3046,8 @@ declare_lint! {
Warn,
"trailing semicolon in macro body used as expression",
@future_incompatible = FutureIncompatibleInfo {
+ reason: FutureIncompatibilityReason::FutureReleaseErrorReportInDeps,
reference: "issue #79813 <https://github.com/rust-lang/rust/issues/79813>",
- reason: FutureIncompatibilityReason::FutureReleaseErrorReportNow,
};
}
@@ -3059,6 +3093,7 @@ declare_lint! {
Warn,
"detects derive helper attributes that are used before they are introduced",
@future_incompatible = FutureIncompatibleInfo {
+ reason: FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps,
reference: "issue #79202 <https://github.com/rust-lang/rust/issues/79202>",
};
}
@@ -3127,6 +3162,7 @@ declare_lint! {
Deny,
"detects usage of `#![cfg_attr(..., crate_type/crate_name = \"...\")]`",
@future_incompatible = FutureIncompatibleInfo {
+ reason: FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps,
reference: "issue #91632 <https://github.com/rust-lang/rust/issues/91632>",
};
}
@@ -3218,6 +3254,7 @@ declare_lint! {
Warn,
"transparent type contains an external ZST that is marked #[non_exhaustive] or contains private fields",
@future_incompatible = FutureIncompatibleInfo {
+ reason: FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps,
reference: "issue #78586 <https://github.com/rust-lang/rust/issues/78586>",
};
}
@@ -3268,6 +3305,7 @@ declare_lint! {
Warn,
"unstable syntax can change at any point in the future, causing a hard error!",
@future_incompatible = FutureIncompatibleInfo {
+ reason: FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps,
reference: "issue #65860 <https://github.com/rust-lang/rust/issues/65860>",
};
}
@@ -3370,12 +3408,14 @@ declare_lint_pass! {
CONFLICTING_REPR_HINTS,
CONST_EVALUATABLE_UNCHECKED,
CONST_ITEM_MUTATION,
+ CONST_PATTERNS_WITHOUT_PARTIAL_EQ,
DEAD_CODE,
DEPRECATED,
DEPRECATED_CFG_ATTR_CRATE_TYPE_NAME,
DEPRECATED_IN_FUTURE,
DEPRECATED_WHERE_CLAUSE_LOCATION,
DUPLICATE_MACRO_ATTRIBUTES,
+ ELIDED_LIFETIMES_IN_ASSOCIATED_CONSTANT,
ELIDED_LIFETIMES_IN_PATHS,
EXPORTED_PRIVATE_DEPENDENCIES,
FFI_UNWIND_CALLS,
@@ -3414,11 +3454,11 @@ declare_lint_pass! {
PATTERNS_IN_FNS_WITHOUT_BODY,
POINTER_STRUCTURAL_MATCH,
PRIVATE_BOUNDS,
- PRIVATE_IN_PUBLIC,
PRIVATE_INTERFACES,
PROC_MACRO_BACK_COMPAT,
PROC_MACRO_DERIVE_RESOLUTION_FALLBACK,
PUB_USE_OF_PRIVATE_EXTERN_CRATE,
+ REFINING_IMPL_TRAIT,
RENAMED_AND_REMOVED_LINTS,
REPR_TRANSPARENT_EXTERNAL_PRIVATE_FIELDS,
RUST_2021_INCOMPATIBLE_CLOSURE_CAPTURES,
@@ -3441,8 +3481,8 @@ declare_lint_pass! {
UNFULFILLED_LINT_EXPECTATIONS,
UNINHABITED_STATIC,
UNKNOWN_CRATE_TYPES,
- UNKNOWN_DIAGNOSTIC_ATTRIBUTES,
UNKNOWN_LINTS,
+ UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES,
UNNAMEABLE_TEST_ITEMS,
UNNAMEABLE_TYPES,
UNREACHABLE_CODE,
@@ -3698,6 +3738,7 @@ declare_lint! {
Warn,
"detects invalid `#[doc(...)]` attributes",
@future_incompatible = FutureIncompatibleInfo {
+ reason: FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps,
reference: "issue #82730 <https://github.com/rust-lang/rust/issues/82730>",
};
}
@@ -3744,8 +3785,8 @@ declare_lint! {
Deny,
"detects usage of old versions of certain proc-macro crates",
@future_incompatible = FutureIncompatibleInfo {
+ reason: FutureIncompatibilityReason::FutureReleaseErrorReportInDeps,
reference: "issue #83125 <https://github.com/rust-lang/rust/issues/83125>",
- reason: FutureIncompatibilityReason::FutureReleaseErrorReportNow,
};
}
@@ -3783,8 +3824,8 @@ declare_lint! {
Allow,
"detects usage of old versions of or-patterns",
@future_incompatible = FutureIncompatibleInfo {
- reference: "<https://doc.rust-lang.org/nightly/edition-guide/rust-2021/or-patterns-macro-rules.html>",
reason: FutureIncompatibilityReason::EditionError(Edition::Edition2021),
+ reference: "<https://doc.rust-lang.org/nightly/edition-guide/rust-2021/or-patterns-macro-rules.html>",
};
}
@@ -3832,8 +3873,8 @@ declare_lint! {
"detects the usage of trait methods which are ambiguous with traits added to the \
prelude in future editions",
@future_incompatible = FutureIncompatibleInfo {
- reference: "<https://doc.rust-lang.org/nightly/edition-guide/rust-2021/prelude.html>",
reason: FutureIncompatibilityReason::EditionError(Edition::Edition2021),
+ reference: "<https://doc.rust-lang.org/nightly/edition-guide/rust-2021/prelude.html>",
};
}
@@ -3869,8 +3910,8 @@ declare_lint! {
Allow,
"identifiers that will be parsed as a prefix in Rust 2021",
@future_incompatible = FutureIncompatibleInfo {
- reference: "<https://doc.rust-lang.org/nightly/edition-guide/rust-2021/reserving-syntax.html>",
reason: FutureIncompatibilityReason::EditionError(Edition::Edition2021),
+ reference: "<https://doc.rust-lang.org/nightly/edition-guide/rust-2021/reserving-syntax.html>",
};
crate_level_only
}
@@ -3917,6 +3958,7 @@ declare_lint! {
Warn,
"use of unsupported calling convention",
@future_incompatible = FutureIncompatibleInfo {
+ reason: FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps,
reference: "issue #87678 <https://github.com/rust-lang/rust/issues/87678>",
};
}
@@ -4257,8 +4299,8 @@ declare_lint! {
Deny,
"impl method assumes more implied bounds than its corresponding trait method",
@future_incompatible = FutureIncompatibleInfo {
+ reason: FutureIncompatibilityReason::FutureReleaseErrorReportInDeps,
reference: "issue #105572 <https://github.com/rust-lang/rust/issues/105572>",
- reason: FutureIncompatibilityReason::FutureReleaseErrorReportNow,
};
}
@@ -4289,8 +4331,8 @@ declare_lint! {
Warn,
"`[u8]` or `str` used in a packed struct with `derive`",
@future_incompatible = FutureIncompatibleInfo {
+ reason: FutureIncompatibilityReason::FutureReleaseErrorReportInDeps,
reference: "issue #107457 <https://github.com/rust-lang/rust/issues/107457>",
- reason: FutureIncompatibilityReason::FutureReleaseErrorReportNow,
};
report_in_external_macro
}
@@ -4333,9 +4375,7 @@ declare_lint! {
/// ### Example
///
/// ```rust,compile_fail
- /// # #![feature(type_privacy_lints)]
/// # #![allow(unused)]
- /// # #![allow(private_in_public)]
/// #![deny(private_interfaces)]
/// struct SemiPriv;
///
@@ -4356,9 +4396,8 @@ declare_lint! {
/// Having something private in primary interface guarantees that
/// the item will be unusable from outer modules due to type privacy.
pub PRIVATE_INTERFACES,
- Allow,
+ Warn,
"private type in primary interface of an item",
- @feature_gate = sym::type_privacy_lints;
}
declare_lint! {
@@ -4369,8 +4408,6 @@ declare_lint! {
/// ### Example
///
/// ```rust,compile_fail
- /// # #![feature(type_privacy_lints)]
- /// # #![allow(private_in_public)]
/// # #![allow(unused)]
/// #![deny(private_bounds)]
///
@@ -4388,9 +4425,8 @@ declare_lint! {
/// Having private types or traits in item bounds makes it less clear what interface
/// the item actually provides.
pub PRIVATE_BOUNDS,
- Allow,
+ Warn,
"private type in secondary interface of an item",
- @feature_gate = sym::type_privacy_lints;
}
declare_lint! {
@@ -4407,7 +4443,7 @@ declare_lint! {
/// pub struct S;
/// }
///
- /// pub fn get_voldemort() -> m::S { m::S }
+ /// pub fn get_unnameable() -> m::S { m::S }
/// # fn main() {}
/// ```
///
@@ -4457,12 +4493,14 @@ declare_lint! {
"impls that are not considered to overlap may be considered to \
overlap in the future",
@future_incompatible = FutureIncompatibleInfo {
+ reason: FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps,
reference: "issue #114040 <https://github.com/rust-lang/rust/issues/114040>",
};
}
declare_lint! {
- /// The `unknown_diagnostic_attributes` lint detects unrecognized diagnostic attributes.
+ /// The `unknown_or_malformed_diagnostic_attributes` lint detects unrecognized or otherwise malformed
+ /// diagnostic attributes.
///
/// ### Example
///
@@ -4474,15 +4512,17 @@ declare_lint! {
///
/// {{produces}}
///
+ ///
/// ### Explanation
///
/// It is usually a mistake to specify a diagnostic attribute that does not exist. Check
/// the spelling, and check the diagnostic attribute listing for the correct name. Also
/// consider if you are using an old version of the compiler, and the attribute
/// is only available in a newer version.
- pub UNKNOWN_DIAGNOSTIC_ATTRIBUTES,
+ pub UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES,
Warn,
- "unrecognized diagnostic attribute"
+ "unrecognized or malformed diagnostic attribute",
+ @feature_gate = sym::diagnostic_namespace;
}
declare_lint! {
@@ -4492,7 +4532,6 @@ declare_lint! {
/// ### Example
///
/// ```rust,compile_fail
- ///
/// #![deny(ambiguous_glob_imports)]
/// pub fn foo() -> u32 {
/// use sub::*;
@@ -4523,7 +4562,92 @@ 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>",
};
}
+
+declare_lint! {
+ /// The `refining_impl_trait` lint detects usages of return-position impl
+ /// traits in trait signatures which are refined by implementations.
+ ///
+ /// ### Example
+ ///
+ /// ```rust,compile_fail
+ /// #![feature(return_position_impl_trait_in_trait)]
+ /// #![deny(refining_impl_trait)]
+ ///
+ /// use std::fmt::Display;
+ ///
+ /// pub trait AsDisplay {
+ /// fn as_display(&self) -> impl Display;
+ /// }
+ ///
+ /// impl<'s> AsDisplay for &'s str {
+ /// fn as_display(&self) -> Self {
+ /// *self
+ /// }
+ /// }
+ ///
+ /// fn main() {
+ /// // users can observe that the return type of
+ /// // `<&str as AsDisplay>::as_display()` is `&str`.
+ /// let x: &str = "".as_display();
+ /// }
+ /// ```
+ ///
+ /// {{produces}}
+ ///
+ /// ### Explanation
+ ///
+ /// Return-position impl trait in traits (RPITITs) desugar to associated types,
+ /// and callers of methods for types where the implementation is known are
+ /// able to observe the types written in the impl signature. This may be
+ /// intended behavior, but may also pose a semver hazard for authors of libraries
+ /// who do not wish to make stronger guarantees about the types than what is
+ /// written in the trait signature.
+ pub REFINING_IMPL_TRAIT,
+ Warn,
+ "impl trait in impl method signature does not match trait method signature",
+}
+
+declare_lint! {
+ /// The `elided_lifetimes_in_associated_constant` lint detects elided lifetimes
+ /// that were erroneously allowed in associated constants.
+ ///
+ /// ### Example
+ ///
+ /// ```rust,compile_fail
+ /// #![deny(elided_lifetimes_in_associated_constant)]
+ ///
+ /// struct Foo;
+ ///
+ /// impl Foo {
+ /// const STR: &str = "hello, world";
+ /// }
+ /// ```
+ ///
+ /// {{produces}}
+ ///
+ /// ### Explanation
+ ///
+ /// Previous version of Rust
+ ///
+ /// Implicit static-in-const behavior was decided [against] for associated
+ /// constants because of ambiguity. This, however, regressed and the compiler
+ /// erroneously treats elided lifetimes in associated constants as lifetime
+ /// parameters on the impl.
+ ///
+ /// This is a [future-incompatible] lint to transition this to a
+ /// hard error in the future.
+ ///
+ /// [against]: https://github.com/rust-lang/rust/issues/38831
+ /// [future-incompatible]: ../index.md#future-incompatible-lints
+ pub ELIDED_LIFETIMES_IN_ASSOCIATED_CONSTANT,
+ Warn,
+ "elided lifetimes cannot be used in associated constants in impls",
+ @future_incompatible = FutureIncompatibleInfo {
+ 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 f350957f7..7ba589c3b 100644
--- a/compiler/rustc_lint_defs/src/lib.rs
+++ b/compiler/rustc_lint_defs/src/lib.rs
@@ -23,8 +23,9 @@ pub mod builtin;
#[macro_export]
macro_rules! pluralize {
+ // Pluralize based on count (e.g., apples)
($x:expr) => {
- if $x != 1 { "s" } else { "" }
+ if $x == 1 { "" } else { "s" }
};
("has", $x:expr) => {
if $x == 1 { "has" } else { "have" }
@@ -346,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,
@@ -379,7 +386,7 @@ impl FutureIncompatibleInfo {
pub const fn default_fields_for_macro() -> Self {
FutureIncompatibleInfo {
reference: "",
- reason: FutureIncompatibilityReason::FutureReleaseError,
+ reason: FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps,
explain_reason: true,
}
}
@@ -572,6 +579,10 @@ pub enum BuiltinLintDiagnostics {
/// The span of the unnecessarily-qualified path to remove.
removal_span: Span,
},
+ AssociatedConstElidedLifetime {
+ elided: bool,
+ span: Span,
+ },
}
/// Lints that are buffered up early on in the `Session` before the
@@ -713,37 +724,29 @@ macro_rules! declare_lint {
);
($(#[$attr:meta])* $vis: vis $NAME: ident, $Level: ident, $desc: expr,
$(@feature_gate = $gate:expr;)?
- $(@future_incompatible = FutureIncompatibleInfo { $($field:ident : $val:expr),* $(,)* }; )?
+ $(@future_incompatible = FutureIncompatibleInfo {
+ reason: $reason:expr,
+ $($field:ident : $val:expr),* $(,)*
+ }; )?
+ $(@edition $lint_edition:ident => $edition_level:ident;)?
$($v:ident),*) => (
$(#[$attr])*
$vis static $NAME: &$crate::Lint = &$crate::Lint {
name: stringify!($NAME),
default_level: $crate::$Level,
desc: $desc,
- edition_lint_opts: None,
is_plugin: false,
$($v: true,)*
- $(feature_gate: Some($gate),)*
+ $(feature_gate: Some($gate),)?
$(future_incompatible: Some($crate::FutureIncompatibleInfo {
+ reason: $reason,
$($field: $val,)*
..$crate::FutureIncompatibleInfo::default_fields_for_macro()
- }),)*
+ }),)?
+ $(edition_lint_opts: Some(($crate::Edition::$lint_edition, $crate::$edition_level)),)?
..$crate::Lint::default_fields_for_macro()
};
);
- ($(#[$attr:meta])* $vis: vis $NAME: ident, $Level: ident, $desc: expr,
- $lint_edition: expr => $edition_level: ident
- ) => (
- $(#[$attr])*
- $vis static $NAME: &$crate::Lint = &$crate::Lint {
- name: stringify!($NAME),
- default_level: $crate::$Level,
- desc: $desc,
- edition_lint_opts: Some(($lint_edition, $crate::Level::$edition_level)),
- report_in_external_macro: false,
- is_plugin: false,
- };
- );
}
#[macro_export]
@@ -782,16 +785,7 @@ macro_rules! declare_tool_lint {
);
}
-/// Declares a static `LintArray` and return it as an expression.
-#[macro_export]
-macro_rules! lint_array {
- ($( $lint:expr ),* ,) => { lint_array!( $($lint),* ) };
- ($( $lint:expr ),*) => {{
- vec![$($lint),*]
- }}
-}
-
-pub type LintArray = Vec<&'static Lint>;
+pub type LintVec = Vec<&'static Lint>;
pub trait LintPass {
fn name(&self) -> &'static str;
@@ -805,7 +799,7 @@ macro_rules! impl_lint_pass {
fn name(&self) -> &'static str { stringify!($ty) }
}
impl $ty {
- pub fn get_lints() -> $crate::LintArray { $crate::lint_array!($($lint),*) }
+ pub fn get_lints() -> $crate::LintVec { vec![$($lint),*] }
}
};
}