Skip to content

Commit

Permalink
Auto merge of rust-lang#88175 - camsteffen:let-desugar-span, r=Manish…
Browse files Browse the repository at this point in the history
…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`
  • Loading branch information
bors committed Oct 3, 2021
2 parents e165c12 + 9c2d52f commit 87bb18e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
1 change: 0 additions & 1 deletion tests/ui/crashes/issues_loop_mut_cond.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#![allow(clippy::blocks_in_if_conditions)]
#![allow(dead_code)]

/// Issue: https://github.com/rust-lang/rust-clippy/issues/2596
Expand Down
2 changes: 0 additions & 2 deletions tests/ui/infinite_loop.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![allow(clippy::blocks_in_if_conditions)]

fn fn_val(i: i32) -> i32 {
unimplemented!()
}
Expand Down
22 changes: 11 additions & 11 deletions tests/ui/infinite_loop.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: variables in the condition are not mutated in the loop body
--> $DIR/infinite_loop.rs:22:11
--> $DIR/infinite_loop.rs:20:11
|
LL | while y < 10 {
| ^^^^^^
Expand All @@ -8,71 +8,71 @@ LL | while y < 10 {
= note: this may lead to an infinite or to a never running loop

error: variables in the condition are not mutated in the loop body
--> $DIR/infinite_loop.rs:27:11
--> $DIR/infinite_loop.rs:25:11
|
LL | while y < 10 && x < 3 {
| ^^^^^^^^^^^^^^^
|
= note: this may lead to an infinite or to a never running loop

error: variables in the condition are not mutated in the loop body
--> $DIR/infinite_loop.rs:34:11
--> $DIR/infinite_loop.rs:32:11
|
LL | while !cond {
| ^^^^^
|
= note: this may lead to an infinite or to a never running loop

error: variables in the condition are not mutated in the loop body
--> $DIR/infinite_loop.rs:78:11
--> $DIR/infinite_loop.rs:76:11
|
LL | while i < 3 {
| ^^^^^
|
= note: this may lead to an infinite or to a never running loop

error: variables in the condition are not mutated in the loop body
--> $DIR/infinite_loop.rs:83:11
--> $DIR/infinite_loop.rs:81:11
|
LL | while i < 3 && j > 0 {
| ^^^^^^^^^^^^^^
|
= note: this may lead to an infinite or to a never running loop

error: variables in the condition are not mutated in the loop body
--> $DIR/infinite_loop.rs:87:11
--> $DIR/infinite_loop.rs:85:11
|
LL | while i < 3 {
| ^^^^^
|
= note: this may lead to an infinite or to a never running loop

error: variables in the condition are not mutated in the loop body
--> $DIR/infinite_loop.rs:102:11
--> $DIR/infinite_loop.rs:100:11
|
LL | while i < 3 {
| ^^^^^
|
= note: this may lead to an infinite or to a never running loop

error: variables in the condition are not mutated in the loop body
--> $DIR/infinite_loop.rs:107:11
--> $DIR/infinite_loop.rs:105:11
|
LL | while i < 3 {
| ^^^^^
|
= note: this may lead to an infinite or to a never running loop

error: variables in the condition are not mutated in the loop body
--> $DIR/infinite_loop.rs:173:15
--> $DIR/infinite_loop.rs:171:15
|
LL | while self.count < n {
| ^^^^^^^^^^^^^^
|
= note: this may lead to an infinite or to a never running loop

error: variables in the condition are not mutated in the loop body
--> $DIR/infinite_loop.rs:181:11
--> $DIR/infinite_loop.rs:179:11
|
LL | while y < 10 {
| ^^^^^^
Expand All @@ -82,7 +82,7 @@ LL | while y < 10 {
= help: rewrite it as `if cond { loop { } }`

error: variables in the condition are not mutated in the loop body
--> $DIR/infinite_loop.rs:188:11
--> $DIR/infinite_loop.rs:186:11
|
LL | while y < 10 {
| ^^^^^^
Expand Down

0 comments on commit 87bb18e

Please sign in to comment.