Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix linting when trailing macro expands to a trailing semi #88996

Merged
merged 1 commit into from
Sep 19, 2021

Conversation

Aaron1011
Copy link
Member

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.

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.
@rust-highfive
Copy link
Collaborator

r? @michaelwoerister

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 16, 2021
@Aaron1011
Copy link
Member Author

r? @petrochenkov

@petrochenkov
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Sep 16, 2021

📌 Commit bd4c967 has been approved by petrochenkov

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 16, 2021
@Mark-Simulacrum Mark-Simulacrum added the beta-nominated Nominated for backporting to the compiler in the beta channel. label Sep 16, 2021
@Mark-Simulacrum
Copy link
Member

beta-nominating this PR, as it's fixing #87757, which is a beta regression (1.56).

JohnTitor added a commit to JohnTitor/rust that referenced this pull request Sep 19, 2021
…trochenkov

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.
bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 19, 2021
Rollup of 10 pull requests

Successful merges:

 - rust-lang#87960 (Suggest replacing an inexisting field for an unmentioned field)
 - rust-lang#88855 (Allow simd_shuffle to accept vectors of any length)
 - rust-lang#88966 (Check for shadowing issues involving block labels)
 - rust-lang#88996 (Fix linting when trailing macro expands to a trailing semi)
 - rust-lang#89017 (fix potential race in AtomicU64 time monotonizer)
 - rust-lang#89021 (Add a separate error for `dyn Trait` in `const fn`)
 - rust-lang#89051 (Add intra-doc links and small changes to `std::os` to be more consistent)
 - rust-lang#89053 (refactor: VecDeques IntoIter fields to private)
 - rust-lang#89055 (Suggest better place to add call parentheses for method expressions wrapped in parentheses)
 - rust-lang#89081 (Fix a typo)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 1c3fce0 into rust-lang:master Sep 19, 2021
@rustbot rustbot added this to the 1.57.0 milestone Sep 19, 2021
@apiraino apiraino added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Sep 22, 2021
@apiraino
Copy link
Contributor

Beta backport accepted as per compiler team on Zulip

@rustbot label +beta-accepted

@rustbot rustbot added the beta-accepted Accepted for backporting to the compiler in the beta channel. label Sep 23, 2021
ehuss pushed a commit to ehuss/rust that referenced this pull request Oct 4, 2021
…trochenkov

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.
@ehuss ehuss mentioned this pull request Oct 4, 2021
@ehuss ehuss removed the beta-nominated Nominated for backporting to the compiler in the beta channel. label Oct 4, 2021
bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 4, 2021
[beta] Beta rollup

* Fix WinUWP std compilation errors due to I/O safety rust-lang#88587
* Disable RemoveZsts in generators to avoid query cycles rust-lang#88979
* Disable the evaluation cache when in intercrate mode rust-lang#88994
* Fix linting when trailing macro expands to a trailing semi rust-lang#88996
* Don't use projection cache or candidate cache in intercrate mode rust-lang#89125
* 2229: Mark insignificant dtor in stdlib rust-lang#89144
* Temporarily rename int_roundings functions to avoid conflicts rust-lang#89184
* [rfc 2229] Drop fully captured upvars in the same order as the regular drop code rust-lang#89208
* Use the correct edition for syntax highlighting doctests rust-lang#89277
* Don't normalize opaque types with escaping late-bound regions rust-lang#89285
* Update Let's Encrypt ROOT CA certificate in dist-(i686|x86_64)-linux docker images rust-lang#89486

Cargo update:
* - [beta] 1.56 backports (rust-lang/cargo#9958)
* - [beta] Revert "When a dependency does not have a version, git or path… (rust-lang/cargo#9912)
* - [beta] Fix rustc --profile=dev unstable check. (rust-lang/cargo#9901)
@Mark-Simulacrum Mark-Simulacrum removed this from the 1.57.0 milestone Oct 6, 2021
@Mark-Simulacrum Mark-Simulacrum added this to the 1.56.0 milestone Oct 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beta-accepted Accepted for backporting to the compiler in the beta channel. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants