]> git.lizzy.rs Git - rust.git/blob - tests/ui/lint/unused_parens_json_suggestion.fixed
Auto merge of #106884 - clubby789:fieldless-enum-debug, r=michaelwoerister
[rust.git] / tests / ui / lint / unused_parens_json_suggestion.fixed
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
13 fn 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
20 fn f() -> bool {
21     loop {
22         if (break { return true }) {
23         }
24     }
25     false
26 }