-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-future-incompatibilityCategory: Future-incompatibility lintsCategory: Future-incompatibility lintsC-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
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
#![doc = in_root!()]
macro_rules! in_root { () => { "" } }
fn main() {}
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
.
Implementation history
- ast: Standardize visiting order for attributes and node IDs #125741 introduced the lint
- out_of_scope_macro_calls: Detect calls inside attributes more precisely #126987 fixed some positives
- Ensure
out_of_scope_macro_calls
lint is registered #127191 integrated it into the allow/warn/deny infrastructure - Mark all deprecation lints in name resolution as deny-by-default and report-in-deps #143929 made the lint deny-by-default and report-in-deps
- XXX turned the lint into a hard error
Metadata
Metadata
Assignees
Labels
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-future-incompatibilityCategory: Future-incompatibility lintsCategory: Future-incompatibility lintsC-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.