From 94a0819fe3a0d679c3042a77bfe6a2afc505daea Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:11:28 +0200 Subject: Adding upstream version 1.66.0+dfsg1. Signed-off-by: Daniel Baumann --- compiler/rustc_lint_defs/src/builtin.rs | 101 +++++++++++++++++++------------- 1 file changed, 59 insertions(+), 42 deletions(-) (limited to 'compiler/rustc_lint_defs/src/builtin.rs') diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs index f00165cd3..61ee467f5 100644 --- a/compiler/rustc_lint_defs/src/builtin.rs +++ b/compiler/rustc_lint_defs/src/builtin.rs @@ -263,37 +263,6 @@ declare_lint! { "operation will cause a panic at runtime" } -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 ", - reason: FutureIncompatibilityReason::FutureReleaseErrorReportNow, - }; - report_in_external_macro -} - declare_lint! { /// The `unused_imports` lint detects imports that are never used. /// @@ -1458,6 +1427,7 @@ declare_lint! { "trait-object types were treated as different depending on marker-trait order", @future_incompatible = FutureIncompatibleInfo { reference: "issue #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; /// @@ -3094,7 +3064,7 @@ declare_lint! { /// /// ### Example /// - /// ```rust + /// ```rust,compile_fail /// #![cfg_attr(debug_assertions, crate_type = "lib")] /// ``` /// @@ -3114,7 +3084,7 @@ declare_lint! { /// rustc instead of `#![cfg_attr(..., crate_type = "...")]` and /// `--crate-name` instead of `#![cfg_attr(..., crate_name = "...")]`. pub DEPRECATED_CFG_ATTR_CRATE_TYPE_NAME, - Warn, + Deny, "detects usage of `#![cfg_attr(..., crate_type/crate_name = \"...\")]`", @future_incompatible = FutureIncompatibleInfo { reference: "issue #91632 ", @@ -3206,12 +3176,62 @@ declare_lint! { /// [future-incompatible]: ../index.md#future-incompatible-lints pub REPR_TRANSPARENT_EXTERNAL_PRIVATE_FIELDS, Warn, - "tranparent type contains an external ZST that is marked #[non_exhaustive] or contains private fields", + "transparent type contains an external ZST that is marked #[non_exhaustive] or contains private fields", @future_incompatible = FutureIncompatibleInfo { reference: "issue #78586 ", }; } +declare_lint! { + /// The `unstable_syntax_pre_expansion` lint detects the use of unstable + /// syntax that is discarded during attribute expansion. + /// + /// ### Example + /// + /// ```rust + /// #[cfg(FALSE)] + /// macro foo() {} + /// ``` + /// + /// {{produces}} + /// + /// ### Explanation + /// + /// The input to active attributes such as `#[cfg]` or procedural macro + /// attributes is required to be valid syntax. Previously, the compiler only + /// gated the use of unstable syntax features after resolving `#[cfg]` gates + /// and expanding procedural macros. + /// + /// To avoid relying on unstable syntax, move the use of unstable syntax + /// into a position where the compiler does not parse the syntax, such as a + /// functionlike macro. + /// + /// ```rust + /// # #![deny(unstable_syntax_pre_expansion)] + /// + /// macro_rules! identity { + /// ( $($tokens:tt)* ) => { $($tokens)* } + /// } + /// + /// #[cfg(FALSE)] + /// identity! { + /// macro foo() {} + /// } + /// ``` + /// + /// This is a [future-incompatible] lint to transition this + /// to a hard error in the future. See [issue #65860] for more details. + /// + /// [issue #65860]: https://github.com/rust-lang/rust/issues/65860 + /// [future-incompatible]: ../index.md#future-incompatible-lints + pub UNSTABLE_SYNTAX_PRE_EXPANSION, + Warn, + "unstable syntax can change at any point in the future, causing a hard error!", + @future_incompatible = FutureIncompatibleInfo { + reference: "issue #65860 ", + }; +} + declare_lint_pass! { /// Does nothing as a lint pass, but registers some `Lint`s /// that are used by other parts of the compiler. @@ -3245,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, @@ -3280,6 +3299,7 @@ declare_lint_pass! { POINTER_STRUCTURAL_MATCH, NONTRIVIAL_STRUCTURAL_MATCH, SOFT_UNSTABLE, + UNSTABLE_SYNTAX_PRE_EXPANSION, INLINE_NO_SANITIZE, BAD_ASM_STYLE, ASM_SUB_REGISTER, @@ -3314,7 +3334,6 @@ declare_lint_pass! { DEPRECATED_CFG_ATTR_CRATE_TYPE_NAME, DUPLICATE_MACRO_ATTRIBUTES, SUSPICIOUS_AUTO_TRAIT_IMPLS, - UNEXPECTED_CFGS, DEPRECATED_WHERE_CLAUSE_LOCATION, TEST_UNSTABLE_LINT, FFI_UNWIND_CALLS, @@ -3357,7 +3376,7 @@ declare_lint! { /// /// ### Example of drop reorder /// - /// ```rust,compile_fail + /// ```rust,edition2018,compile_fail /// #![deny(rust_2021_incompatible_closure_captures)] /// # #![allow(unused)] /// @@ -3393,7 +3412,7 @@ declare_lint! { /// /// ### Example of auto-trait /// - /// ```rust,compile_fail + /// ```rust,edition2018,compile_fail /// #![deny(rust_2021_incompatible_closure_captures)] /// use std::thread; /// @@ -3919,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, @@ -3938,8 +3957,6 @@ declare_lint! { /// ### Example /// /// ```rust - /// #![feature(generic_associated_types)] - /// /// trait Trait { /// type Assoc<'a> where Self: 'a; /// } -- cgit v1.2.3