fork/rust
git clone https://git.julia.blue/fork/rust
3bcad65fbf6
master
1// compile-flags: --error-format json 2// run-rustfix 3 4// The output for humans should just highlight the whole span without showing 5// the suggested replacement, but we also want to test that suggested 6// replacement only removes one set of parentheses, rather than naïvely 7// stripping away any starting or ending parenthesis characters—hence this 8// test of the JSON error format. 9 10#![deny(unused_parens)] 11#![allow(unreachable_code)] 12 13fn main() { 14 15 let _b = false; 16 17 if _b { //~ ERROR unnecessary parentheses 18 println!("hello"); 19 } 20 21 f(); 22 23} 24 25fn f() -> bool { 26 let c = false; 27 28 if c { //~ ERROR unnecessary parentheses 29 println!("next"); 30 } 31 32 if c { //~ ERROR unnecessary parentheses 33 println!("prev"); 34 } 35 36 while false && true { 37 if c { //~ ERROR unnecessary parentheses 38 println!("norm"); 39 } 40 41 } 42 43 while true && false { //~ ERROR unnecessary parentheses 44 for _ in 0 .. 3 { //~ ERROR unnecessary parentheses 45 println!("e~") 46 } 47 } 48 49 for _ in 0 .. 3 { //~ ERROR unnecessary parentheses 50 while true && false { //~ ERROR unnecessary parentheses 51 println!("e~") 52 } 53 } 54 55 56 loop { 57 if (break { return true }) { 58 } 59 } 60 false 61}