Uh oh!
There was an error while loading. Please reload this page.
Compute a better lint_node_id during expansion - #87146
Conversation
rust-highfive
commented
Jul 15, 2021
r? @jackh726 (rust-highfive has picked a reviewer for you, use r? to override) |
Aaron1011
commented
Jul 15, 2021
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
3d3f11e to
1f2711bCompare
This comment has been minimized.
This comment has been minimized.
1f2711b to
6b9b1aeCompare
This comment has been minimized.
This comment has been minimized.
Aaron1011
commented
Jul 15, 2021
@petrochenkov: This PR is now ready for review |
There are about 30 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. Apparently it does, because (I'll check which nodes can be immediate parents of macro invocations tomorrow.) |
Looks like I was wrong, pretty much anything with a However, it's not necessary to track them all, we only need to track parent nodes (not necessarily immediate) supporting attributes like |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
4ad9fe7 to
cb862d5CompareAaron1011
commented
Jul 17, 2021
@petrochenkov: I've added the |
petrochenkov
commented
Jul 17, 2021
@bors r+ |
bors
commented
Jul 17, 2021
📌 Commit cb862d5cac071a21735886dac9878ffb4562ae9f has been approved by |
bors
commented
Jul 17, 2021
☔ The latest upstream changes (presumably #86676) made this pull request unmergeable. Please resolve the merge conflicts. |
When we need to emit a lint at a macro invocation, we currently use the `NodeId` of its parent definition (e.g. the enclosing function). This means that any `#[allow]` / `#[deny]` attributes placed 'closer' to the macro (e.g. on an enclosing block or statement) will have no effect. This commit computes a better `lint_node_id` in `InvocationCollector`. When we visit/flat_map an AST node, we assign it a `NodeId` (earlier than we normally would), and store than `NodeId` in current `ExpansionData`. When we collect a macro invocation, the current `lint_node_id` gets cloned along with our `ExpansionData`, allowing it to be used if we need to emit a lint later on. This improves the handling of `#[allow]` / `#[deny]` for `SEMICOLON_IN_EXPRESSIONS_FROM_MACROS` and some `asm!`-related lints. The 'legacy derive helpers' lint retains its current behavior (I've inlined the now-removed `lint_node_id` function), since there isn't an `ExpansionData` readily available.
cb862d5 to
1c1c794CompareAaron1011
commented
Jul 18, 2021
@bors r=petrochenkov |
bors
commented
Jul 18, 2021
📌 Commit 1c1c794 has been approved by |
bors
commented
Jul 18, 2021
⌛ Testing commit 1c1c794 with merge 9cc5500d72f84850fbde80fdf5520e2c97c1626d... |
bors
commented
Jul 18, 2021
💥 Test timed out |
Aaron1011
commented
Jul 18, 2021
@bors retry |
rust-log-analyzer
commented
Jul 18, 2021
bors
commented
Jul 19, 2021
bors
commented
Jul 19, 2021
☀️ Test successful - checks-actions |
When we need to emit a lint at a macro invocation, we currently use the
NodeIdof its parent definition (e.g. the enclosing function). Thismeans that any
#[allow]/#[deny]attributes placed 'closer' to themacro (e.g. on an enclosing block or statement) will have no effect.
This commit computes a better
lint_node_idinInvocationCollector.When we visit/flat_map an AST node, we assign it a
NodeId(earlierthan we normally would), and store than
NodeIdin currentExpansionData. When we collect a macro invocation, the currentlint_node_idgets cloned along with ourExpansionData, allowing itto be used if we need to emit a lint later on.
This improves the handling of
#[allow]/#[deny]forSEMICOLON_IN_EXPRESSIONS_FROM_MACROSand someasm!-related lints.The 'legacy derive helpers' lint retains its current behavior
(I've inlined the now-removed
lint_node_idfunction), sincethere isn't an
ExpansionDatareadily available.