Skip to content

Commit 87bb18e

Browse files
committed
Auto merge of rust-lang#88175 - camsteffen:let-desugar-span, r=Manishearth
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`
2 parents e165c12 + 9c2d52f commit 87bb18e

File tree

3 files changed

+11
-14
lines changed

3 files changed

+11
-14
lines changed

tests/ui/crashes/issues_loop_mut_cond.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![allow(clippy::blocks_in_if_conditions)]
21
#![allow(dead_code)]
32

43
/// Issue: https://github.com./rust-lang/rust-clippy/issues/2596

tests/ui/infinite_loop.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![allow(clippy::blocks_in_if_conditions)]
2-
31
fn fn_val(i: i32) -> i32 {
42
unimplemented!()
53
}

tests/ui/infinite_loop.stderr

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: variables in the condition are not mutated in the loop body
2-
--> $DIR/infinite_loop.rs:22:11
2+
--> $DIR/infinite_loop.rs:20:11
33
|
44
LL | while y < 10 {
55
| ^^^^^^
@@ -8,71 +8,71 @@ LL | while y < 10 {
88
= note: this may lead to an infinite or to a never running loop
99

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

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

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

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

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

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

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

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

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

8484
error: variables in the condition are not mutated in the loop body
85-
--> $DIR/infinite_loop.rs:188:11
85+
--> $DIR/infinite_loop.rs:186:11
8686
|
8787
LL | while y < 10 {
8888
| ^^^^^^

0 commit comments

Comments
 (0)