-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #6473 - phansch:split-up-ui-test, r=flip1995
UI Tests: Separate suspicious_else_formatting tests Was briefly looking into #3864 when I saw that the tests could benefit from being in their own file. --- changelog: none
- Loading branch information
Showing
4 changed files
with
164 additions
and
168 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
#![warn(clippy::suspicious_else_formatting)] | ||
|
||
fn foo() -> bool { | ||
true | ||
} | ||
|
||
#[rustfmt::skip] | ||
fn main() { | ||
// weird `else` formatting: | ||
if foo() { | ||
} { | ||
} | ||
|
||
if foo() { | ||
} if foo() { | ||
} | ||
|
||
let _ = { // if as the last expression | ||
let _ = 0; | ||
|
||
if foo() { | ||
} if foo() { | ||
} | ||
else { | ||
} | ||
}; | ||
|
||
let _ = { // if in the middle of a block | ||
if foo() { | ||
} if foo() { | ||
} | ||
else { | ||
} | ||
|
||
let _ = 0; | ||
}; | ||
|
||
if foo() { | ||
} else | ||
{ | ||
} | ||
|
||
if foo() { | ||
} | ||
else | ||
{ | ||
} | ||
|
||
if foo() { | ||
} else | ||
if foo() { // the span of the above error should continue here | ||
} | ||
|
||
if foo() { | ||
} | ||
else | ||
if foo() { // the span of the above error should continue here | ||
} | ||
|
||
// those are ok: | ||
if foo() { | ||
} | ||
{ | ||
} | ||
|
||
if foo() { | ||
} else { | ||
} | ||
|
||
if foo() { | ||
} | ||
else { | ||
} | ||
|
||
if foo() { | ||
} | ||
if foo() { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
error: this looks like an `else {..}` but the `else` is missing | ||
--> $DIR/suspicious_else_formatting.rs:11:6 | ||
| | ||
LL | } { | ||
| ^ | ||
| | ||
= note: `-D clippy::suspicious-else-formatting` implied by `-D warnings` | ||
= note: to remove this lint, add the missing `else` or add a new line before the next block | ||
|
||
error: this looks like an `else if` but the `else` is missing | ||
--> $DIR/suspicious_else_formatting.rs:15:6 | ||
| | ||
LL | } if foo() { | ||
| ^ | ||
| | ||
= note: to remove this lint, add the missing `else` or add a new line before the second `if` | ||
|
||
error: this looks like an `else if` but the `else` is missing | ||
--> $DIR/suspicious_else_formatting.rs:22:10 | ||
| | ||
LL | } if foo() { | ||
| ^ | ||
| | ||
= note: to remove this lint, add the missing `else` or add a new line before the second `if` | ||
|
||
error: this looks like an `else if` but the `else` is missing | ||
--> $DIR/suspicious_else_formatting.rs:30:10 | ||
| | ||
LL | } if foo() { | ||
| ^ | ||
| | ||
= note: to remove this lint, add the missing `else` or add a new line before the second `if` | ||
|
||
error: this is an `else {..}` but the formatting might hide it | ||
--> $DIR/suspicious_else_formatting.rs:39:6 | ||
| | ||
LL | } else | ||
| ______^ | ||
LL | | { | ||
| |____^ | ||
| | ||
= note: to remove this lint, remove the `else` or remove the new line between `else` and `{..}` | ||
|
||
error: this is an `else {..}` but the formatting might hide it | ||
--> $DIR/suspicious_else_formatting.rs:44:6 | ||
| | ||
LL | } | ||
| ______^ | ||
LL | | else | ||
LL | | { | ||
| |____^ | ||
| | ||
= note: to remove this lint, remove the `else` or remove the new line between `else` and `{..}` | ||
|
||
error: this is an `else if` but the formatting might hide it | ||
--> $DIR/suspicious_else_formatting.rs:50:6 | ||
| | ||
LL | } else | ||
| ______^ | ||
LL | | if foo() { // the span of the above error should continue here | ||
| |____^ | ||
| | ||
= note: to remove this lint, remove the `else` or remove the new line between `else` and `if` | ||
|
||
error: this is an `else if` but the formatting might hide it | ||
--> $DIR/suspicious_else_formatting.rs:55:6 | ||
| | ||
LL | } | ||
| ______^ | ||
LL | | else | ||
LL | | if foo() { // the span of the above error should continue here | ||
| |____^ | ||
| | ||
= note: to remove this lint, remove the `else` or remove the new line between `else` and `if` | ||
|
||
error: aborting due to 8 previous errors | ||
|