Allow allman style braces in suspicious_else_formatting

This commit is contained in:
Jason Newcomb 2021-04-15 11:49:45 -04:00
parent 586a99348c
commit 559deddb3b
No known key found for this signature in database
GPG key ID: DA59E8643A37ED06
3 changed files with 68 additions and 16 deletions

View file

@ -40,6 +40,7 @@ fn main() {
{
}
// This is fine, though weird. Allman style braces on the else.
if foo() {
}
else
@ -76,4 +77,29 @@ fn main() {
}
if foo() {
}
// Almost Allman style braces. Lint these.
if foo() {
}
else
{
}
if foo() {
}
else
{
}
// #3864 - Allman style braces
if foo()
{
}
else
{
}
}

View file

@ -41,19 +41,8 @@ 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
--> $DIR/suspicious_else_formatting.rs:51:6
|
LL | } else
| ______^
@ -63,7 +52,7 @@ 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
--> $DIR/suspicious_else_formatting.rs:56:6
|
LL | }
| ______^
@ -73,5 +62,29 @@ 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
error: this is an `else {..}` but the formatting might hide it
--> $DIR/suspicious_else_formatting.rs:83:6
|
LL | }
| ______^
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 {..}` but the formatting might hide it
--> $DIR/suspicious_else_formatting.rs:91:6
|
LL | }
| ______^
LL | | else
LL | |
LL | | {
| |____^
|
= note: to remove this lint, remove the `else` or remove the new line between `else` and `{..}`
error: aborting due to 9 previous errors