diff options
Diffstat (limited to 'compiler/rustc_lint_defs/src/builtin.rs')
| -rw-r--r-- | compiler/rustc_lint_defs/src/builtin.rs | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs index 265779c9374..a023d6161df 100644 --- a/compiler/rustc_lint_defs/src/builtin.rs +++ b/compiler/rustc_lint_defs/src/builtin.rs @@ -4945,3 +4945,42 @@ declare_lint! { reference: "issue #123757 <https://github.com/rust-lang/rust/issues/123757>", }; } + +declare_lint! { + /// The `out_of_scope_macro_calls` lint detects `macro_rules` called when they are not in scope, + /// above their definition, which may happen in key-value attributes. + /// + /// ### Example + /// + /// ```rust + /// #![doc = in_root!()] + /// + /// macro_rules! in_root { () => { "" } } + /// + /// fn main() {} + /// ``` + /// + /// {{produces}} + /// + /// ### Explanation + /// + /// The scope in which a `macro_rules` item is visible starts at that item and continues + /// below it. This is more similar to `let` than to other items, which are in scope both above + /// and below their definition. + /// Due to a bug `macro_rules` were accidentally in scope inside some key-value attributes + /// above their definition. The lint catches such cases. + /// To address the issue turn the `macro_rules` into a regularly scoped item by importing it + /// with `use`. + /// + /// This is a [future-incompatible] lint to transition this to a + /// hard error in the future. + /// + /// [future-incompatible]: ../index.md#future-incompatible-lints + pub OUT_OF_SCOPE_MACRO_CALLS, + Warn, + "detects out of scope calls to `macro_rules` in key-value attributes", + @future_incompatible = FutureIncompatibleInfo { + reason: FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps, + reference: "issue #124535 <https://github.com/rust-lang/rust/issues/124535>", + }; +} |
