rust/compiler/rustc_expand/src
Aaron Hill bd4c9676c7
Fix linting when trailing macro expands to a trailing semi
When a macro is used in the trailing expression position of a block
(e.g. `fn foo() { my_macro!() }`), we currently parse it as an
expression, rather than a statement. As a result, we ended up
using the `NodeId` of the containing statement as our `lint_node_id`,
even though we don't normally do this for macro calls.

If such a macro expands to an expression with a `#[cfg]` attribute,
then the trailing statement can get removed entirely. This lead to
an ICE, since we were usng the `NodeId` of the expression to emit
a lint.

Ths commit makes us skip updating `lint_node_id` when handling
a macro in trailing expression position. This will cause us to
lint at the closest parent of the macro call.
2021-09-15 19:36:28 -05:00
..
mbe Auto merge of #88262 - klensy:pprust-cow, r=nagisa 2021-08-29 17:46:29 +00: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 Auto merge of #84373 - cjgillot:resolve-span, r=michaelwoerister,petrochenkov 2021-09-11 23:35:28 +00:00
build.rs Detect bare blocks with type ascription that were meant to be a struct literal 2021-09-03 14:43:04 +00:00
config.rs Use if-let guards in the codebase 2021-08-25 20:24:35 +02:00
expand.rs Fix linting when trailing macro expands to a trailing semi 2021-09-15 19:36:28 -05:00
lib.rs Bump stage0 compiler to 1.56 2021-09-08 20:51:05 -04:00
mbe.rs fix few typos 2021-04-19 15:57:08 +03:00
module.rs Use if-let guards in the codebase 2021-08-25 20:24:35 +02:00
placeholders.rs expand: Treat more macro calls as statement macro calls 2021-09-02 14:14:38 +03:00
proc_macro_server.rs Auto merge of #84373 - cjgillot:resolve-span, r=michaelwoerister,petrochenkov 2021-09-11 23:35:28 +00:00
proc_macro.rs rustc_expand: Remove redundant field from proc macro expander structures 2021-07-10 23:22:27 +03:00
tests.rs Rework SESSION_GLOBALS API to prevent overwriting it 2021-07-08 16:16:28 +02:00