-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding
BreakValue
to UnusedDelimsCtx to make UnusedParens
and `Un…
…usedBraces` checking `break`
- Loading branch information
Showing
13 changed files
with
182 additions
and
44 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
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
32 changes: 32 additions & 0 deletions
32
tests/ui/lint/unused/unused-parens-assign-expr-in-ret-issue-131989.fixed
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,32 @@ | ||
//@ run-rustfix | ||
#![deny(unused_parens)] | ||
#![allow(unreachable_code)] | ||
|
||
fn foo() { | ||
loop { | ||
break (_ = 42); | ||
// lint unused_parens should not be triggered here. | ||
} | ||
|
||
let _ = loop { | ||
let a = 1; | ||
let b = 2; | ||
break a + b; //~ERROR unnecessary parentheses | ||
}; | ||
|
||
loop { | ||
if break return () { | ||
//~^ ERROR unnecessary parentheses | ||
} | ||
if break return () { | ||
//~^ ERROR unnecessary parentheses | ||
} | ||
} | ||
|
||
return (_ = 42); | ||
// lint unused_parens should not be triggered here. | ||
} | ||
|
||
fn main() { | ||
let _ = foo(); | ||
} |
29 changes: 26 additions & 3 deletions
29
tests/ui/lint/unused/unused-parens-assign-expr-in-ret-issue-131989.rs
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 |
---|---|---|
@@ -1,9 +1,32 @@ | ||
//@ check-pass | ||
#![warn(unused_parens)] | ||
//@ run-rustfix | ||
#![deny(unused_parens)] | ||
#![allow(unreachable_code)] | ||
|
||
fn foo() { | ||
loop { | ||
break (_ = 42); | ||
// lint unused_parens should not be triggered here. | ||
} | ||
|
||
let _ = loop { | ||
let a = 1; | ||
let b = 2; | ||
break (a + b); //~ERROR unnecessary parentheses | ||
}; | ||
|
||
loop { | ||
if (break return ()) { | ||
//~^ ERROR unnecessary parentheses | ||
} | ||
if break (return ()) { | ||
//~^ ERROR unnecessary parentheses | ||
} | ||
} | ||
|
||
return (_ = 42); | ||
// lint unused_parens should not be triggered here. | ||
} | ||
|
||
fn main() {} | ||
fn main() { | ||
let _ = foo(); | ||
} |
Oops, something went wrong.