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

Add expansion to while desugar spans #88175

Merged
merged 1 commit into from
Oct 4, 2021

Conversation

camsteffen
Copy link
Contributor

In the same vein as #88163, this reverts a change in Clippy behavior as a result of #80357 (and reverts some #[allow]s): This changes clippy::blocks_in_if_conditions to not fire on while loops. Though we might actually want Clippy to lint those cases, we should introduce the change purposefully, with tests, and possibly under a different lint name.

The actual change here is to add a desugaring expansion to the spans when lowering a while loop.

r? @Manishearth

@rust-highfive
Copy link
Collaborator

Some changes occurred in src/tools/clippy.

cc @rust-lang/clippy

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 20, 2021
@rust-log-analyzer

This comment has been minimized.

@Manishearth
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Aug 20, 2021

📌 Commit 48ac8c81573c25dd73a3f6fe0ba57b089b5799fb has been approved by Manishearth

@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 Aug 20, 2021
@camsteffen camsteffen force-pushed the let-desugar-span branch 2 times, most recently from 11d1e6c to 15e8b4c Compare August 20, 2021 12:30
@camsteffen
Copy link
Contributor Author

camsteffen commented Aug 20, 2021

Fix formatting @bors r=Manishearth

@camsteffen
Copy link
Contributor Author

@bors r=Manishearth

@bors
Copy link
Contributor

bors commented Aug 20, 2021

📌 Commit 15e8b4c7a9c087d36c1c09bafb33d7f0ebbb0ad4 has been approved by Manishearth

@rust-log-analyzer

This comment has been minimized.

@camsteffen
Copy link
Contributor Author

@bors r-

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Aug 20, 2021
@rust-log-analyzer

This comment has been minimized.

@camsteffen
Copy link
Contributor Author

Tweaked some error handling to maintain test output.

@rust-log-analyzer

This comment has been minimized.

@camsteffen
Copy link
Contributor Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 20, 2021
@rustbot
Copy link
Collaborator

rustbot commented Aug 20, 2021

@Manishearth

@inquisitivecrystal inquisitivecrystal added A-clippy Area: Clippy T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Aug 24, 2021
@bors
Copy link
Contributor

bors commented Sep 1, 2021

☔ The latest upstream changes (presumably #87688) made this pull request unmergeable. Please resolve the merge conflicts.

@JohnCSimon JohnCSimon added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 20, 2021
@bors
Copy link
Contributor

bors commented Sep 29, 2021

☔ The latest upstream changes (presumably #89328) made this pull request unmergeable. Please resolve the merge conflicts.

@camsteffen
Copy link
Contributor Author

Hey @Manishearth, I'm awaiting your review since I added some changes after your first review.

@Manishearth
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Oct 3, 2021

📌 Commit 67ea84d has been approved by Manishearth

@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 Oct 3, 2021
@bors
Copy link
Contributor

bors commented Oct 3, 2021

⌛ Testing commit 67ea84d with merge e737694...

@bors
Copy link
Contributor

bors commented Oct 4, 2021

☀️ Test successful - checks-actions
Approved by: Manishearth
Pushing e737694 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Oct 4, 2021
@bors bors merged commit e737694 into rust-lang:master Oct 4, 2021
@rustbot rustbot added this to the 1.57.0 milestone Oct 4, 2021
@camsteffen camsteffen deleted the let-desugar-span branch October 4, 2021 00:47
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (e737694): comparison url.

Summary: This benchmark run did not return any relevant changes.

If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf.

@rustbot label: -perf-regression

flip1995 pushed a commit to flip1995/rust that referenced this pull request Oct 7, 2021
…earth

Add expansion to while desugar spans

In the same vein as rust-lang#88163, this reverts a change in Clippy behavior as a result of rust-lang#80357 (and reverts some `#[allow]`s): This changes `clippy::blocks_in_if_conditions` to not fire on `while` loops. Though we might actually want Clippy to lint those cases, we should introduce the change purposefully, with tests, and possibly under a different lint name.

The actual change here is to add a desugaring expansion to the spans when lowering a `while` loop.

r? `@Manishearth`
flip1995 added a commit to flip1995/rust-clippy that referenced this pull request Oct 8, 2021
Before this lint didn't trigger on macros. With rust-lang/rust#88175
this isn't enough anymore. In this PR a `WhileLoop` desugaring kind was
introduced. This overrides the span of expanded expressions when
lowering the while loop. So if a while loop is in a macro, the
expressions that it expands to are no longer marked with
`ExpnKind::Macro`, but with `ExpnKind::Desugaring`. In general, this is
the correct behavior and the same that is done for `ForLoop`s. It just
tripped up this lint.
bors added a commit to rust-lang/rust-clippy that referenced this pull request Oct 8, 2021
…steffen

Don't trigger semicolon_if_nothing_returned in expanded code

Fixes #7768

Before, this lint didn't trigger on macros. With rust-lang/rust#88175
this isn't enough anymore. In this PR a `WhileLoop` desugaring kind was
introduced. This overrides the span of expanded expressions when
lowering the while loop. So if a while loop is in a macro, the
expressions that it expands to are no longer marked with
`ExpnKind::Macro`, but with `ExpnKind::Desugaring`. In general, this is
the correct behavior and the same that is done for `ForLoop`s. It just
tripped up this lint.

r? `@camsteffen`

changelog: [`semicolon_if_nothing_returned`]: Fix regression on macros containing while loops
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-clippy Area: Clippy merged-by-bors This PR was explicitly merged by bors. 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