rust/compiler/rustc_expand/src
Aaron Hill ddd544856e
Compute a better lint_node_id during expansion
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.
2021-07-17 23:03:56 -05:00
..
mbe Compute a better lint_node_id during expansion 2021-07-17 23:03:56 -05:00
mut_visit Rework SESSION_GLOBALS API to prevent overwriting it 2021-07-08 16:16:28 +02:00
parse Rework SESSION_GLOBALS API to prevent overwriting it 2021-07-08 16:16:28 +02:00
tokenstream Rework SESSION_GLOBALS API to prevent overwriting it 2021-07-08 16:16:28 +02:00
base.rs Compute a better lint_node_id during expansion 2021-07-17 23:03:56 -05:00
build.rs Use AttrVec for Arm, FieldDef, and Variant 2021-06-17 08:04:54 +09:00
config.rs Unify rustc and rustdoc parsing of cfg() 2021-05-03 12:49:43 -04:00
expand.rs Compute a better lint_node_id during expansion 2021-07-17 23:03:56 -05:00
lib.rs Include macro name in 'local ambiguity' error 2021-06-07 20:17:48 -05:00
mbe.rs fix few typos 2021-04-19 15:57:08 +03:00
module.rs E0583: Include secondary path in error message 2021-05-06 09:40:05 +08:00
placeholders.rs ast/hir: Rename field-related structures 2021-03-16 11:41:24 +03:00
proc_macro.rs rustc_expand: Remove redundant field from proc macro expander structures 2021-07-10 23:22:27 +03:00
proc_macro_server.rs rustc_expand: Simplify span quoting in proc macro server 2021-07-11 00:39:37 +03:00
tests.rs Rework SESSION_GLOBALS API to prevent overwriting it 2021-07-08 16:16:28 +02:00