rust/compiler/rustc_resolve/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
..
late Fix garbled suggestion for missing lifetime specifier 2021-06-28 00:56:24 +02:00
build_reduced_graph.rs Use LocalExpnId where possible. 2021-07-17 19:41:02 +02:00
check_unused.rs Attach TokenStream to ast::Visibility 2020-09-10 17:33:06 -04:00
def_collector.rs Use LocalExpnId where possible. 2021-07-17 19:41:02 +02:00
diagnostics.rs Change type param -> generic param 2021-07-14 19:22:39 +01:00
imports.rs Use LocalExpnId where possible. 2021-07-17 19:41:02 +02:00
late.rs Add support for using qualified paths with structs in expression and pattern 2021-06-10 13:18:41 +02:00
lib.rs Use LocalExpnId where possible. 2021-07-17 19:41:02 +02:00
macros.rs Compute a better lint_node_id during expansion 2021-07-17 23:03:56 -05:00