Compute a better lint_node_id
during expansion by Aaron1011 · Pull Request #87146 · rust-lang/rust (original) (raw)
There are about 30 NodeId
s in AST, but assign_id!
is used 19 times in this PR.
This means only some NodeId
s can be assigned to lint_node_id
.
I'm not sure which subset of NodeId
s is used for linting in this PR, and which subset should be used.
I think it's enough to track IDs that can be immediate parents of macro invocations (with "macro invocations" including uses of macro attributes).
If we are considering attributes, then some interesting situations may arise.
For example, does this example produce a warning?
#[allow(deprecated)]
#[deprecated_macro_attribute_equivalent_to_cfg_false]
struct S;
Apparently it does, because struct S;
disappears before getting a meaningful NodeId
(the ID is assigned after expanding all macro attributes), so struct S;
is not an immediate parent of the macro attribute invocation, the containing module/crate is.
(Anyway, this snippet probably needs to be added as a test case.)
(I'll check which nodes can be immediate parents of macro invocations tomorrow.)