X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=compiler%2Frustc_lint_defs%2Fsrc%2Fbuiltin.rs;h=da62ad3a6b1cdced003d53e394bb85c296174b02;hb=c5990dd8ad83fa1dccbc105102bceca0728977c3;hp=a8bf1ce51bb74e589bfa295230ed7d458bcdeb80;hpb=ac37c326aeccb5710f18235b18015750e6484d66;p=rust.git diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs index a8bf1ce51bb..da62ad3a6b1 100644 --- a/compiler/rustc_lint_defs/src/builtin.rs +++ b/compiler/rustc_lint_defs/src/builtin.rs @@ -5,10 +5,48 @@ //! compiler code, rather than using their own custom pass. Those //! lints are all available in `rustc_lint::builtin`. +// ignore-tidy-filelength + use crate::{declare_lint, declare_lint_pass}; use rustc_span::edition::Edition; use rustc_span::symbol::sym; +declare_lint! { + /// The `forbidden_lint_groups` lint detects violations of + /// `forbid` applied to a lint group. Due to a bug in the compiler, + /// these used to be overlooked entirely. They now generate a warning. + /// + /// ### Example + /// + /// ```rust + /// #![forbid(warnings)] + /// #![deny(bad_style)] + /// + /// fn main() {} + /// ``` + /// + /// {{produces}} + /// + /// ### Recommended fix + /// + /// If your crate is using `#![forbid(warnings)]`, + /// we recommend that you change to `#![deny(warnings)]`. + /// + /// ### Explanation + /// + /// Due to a compiler bug, applying `forbid` to lint groups + /// previously had no effect. The bug is now fixed but instead of + /// enforcing `forbid` we issue this future-compatibility warning + /// to avoid breaking existing crates. + pub FORBIDDEN_LINT_GROUPS, + Warn, + "applying forbid to lint-groups", + @future_incompatible = FutureIncompatibleInfo { + reference: "issue #81670 ", + edition: None, + }; +} + declare_lint! { /// The `ill_formed_attribute_input` lint detects ill-formed attribute /// inputs that were previously accepted and used in practice. @@ -255,6 +293,10 @@ pub CONST_ERR, Deny, "constant evaluation encountered erroneous expression", + @future_incompatible = FutureIncompatibleInfo { + reference: "issue #71800 ", + edition: None, + }; report_in_external_macro } @@ -2884,6 +2926,7 @@ /// Does nothing as a lint pass, but registers some `Lint`s /// that are used by other parts of the compiler. HardwiredLints => [ + FORBIDDEN_LINT_GROUPS, ILLEGAL_FLOATING_POINT_LITERAL_PATTERN, ARITHMETIC_OVERFLOW, UNCONDITIONAL_PANIC, @@ -2968,6 +3011,7 @@ UNSUPPORTED_NAKED_FUNCTIONS, MISSING_ABI, SEMICOLON_IN_EXPRESSIONS_FROM_MACROS, + DISJOINT_CAPTURE_DROP_REORDER, ] } @@ -2994,6 +3038,51 @@ "detects doc comments that aren't used by rustdoc" } +declare_lint! { + /// The `disjoint_capture_drop_reorder` lint detects variables that aren't completely + /// captured when the feature `capture_disjoint_fields` is enabled and it affects the Drop + /// order of at least one path starting at this variable. + /// + /// ### Example + /// + /// ```rust,compile_fail + /// # #![deny(disjoint_capture_drop_reorder)] + /// # #![allow(unused)] + /// struct FancyInteger(i32); + /// + /// impl Drop for FancyInteger { + /// fn drop(&mut self) { + /// println!("Just dropped {}", self.0); + /// } + /// } + /// + /// struct Point { x: FancyInteger, y: FancyInteger } + /// + /// fn main() { + /// let p = Point { x: FancyInteger(10), y: FancyInteger(20) }; + /// + /// let c = || { + /// let x = p.x; + /// }; + /// + /// c(); + /// + /// // ... More code ... + /// } + /// ``` + /// + /// {{produces}} + /// + /// ### Explanation + /// + /// In the above example `p.y` will be dropped at the end of `f` instead of with `c` if + /// the feature `capture_disjoint_fields` is enabled. + pub DISJOINT_CAPTURE_DROP_REORDER, + Allow, + "Drop reorder because of `capture_disjoint_fields`" + +} + declare_lint_pass!(UnusedDocComment => [UNUSED_DOC_COMMENTS]); declare_lint! {