Rollup merge of #71910 - mibac138:necessary-paren, r=cuviper
Fix unused_parens false positive when using binary operations Fixes #71290 r? @cuviper who provided instructions
This commit is contained in:
commit
b20b200d2e
2 changed files with 43 additions and 4 deletions
23
src/test/ui/lint/issue-71290-unused-paren-binop.rs
Normal file
23
src/test/ui/lint/issue-71290-unused-paren-binop.rs
Normal file
|
|
@ -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() {}
|
||||
Loading…
Add table
Add a link
Reference in a new issue