forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#71910 - mibac138:necessary-paren, r=cuviper
Fix unused_parens false positive when using binary operations Fixes rust-lang#71290 r? @cuviper who provided instructions
- Loading branch information
Showing
2 changed files
with
43 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// check-pass | ||
// Make sure unused parens lint doesn't emit a false positive. | ||
// See https://github.com/rust-lang/rust/issues/71290 for details. | ||
#![deny(unused_parens)] | ||
|
||
fn x() -> u8 { | ||
({ 0 }) + 1 | ||
} | ||
|
||
fn y() -> u8 { | ||
({ 0 } + 1) | ||
} | ||
|
||
pub fn foo(a: bool, b: bool) -> u8 { | ||
(if a { 1 } else { 0 } + if b { 1 } else { 0 }) | ||
} | ||
|
||
pub fn bar() -> u8 { | ||
// Make sure nested expressions are handled correctly as well | ||
({ 0 } + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9) | ||
} | ||
|
||
fn main() {} |