fork/rust

git clone https://git.julia.blue/fork/rust

borsAuto merge of #69444 - pietroalbini:stable-next-final-v2-new, r=pietroalbinif3e1a954d2e

1.41.1
747 B26 linesraw
1// compile-flags: --error-format json -Zunstable-options
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    // We want to suggest the properly-balanced expression `1 / (2 + 3)`, not
15    // the malformed `1 / (2 + 3`
16    let _a = 1 / (2 + 3); //~ERROR unnecessary parentheses
17    f();
18}
19
20fn f() -> bool {
21    loop {
22        if (break { return true }) {
23        }
24    }
25    false
26}