fork/rust

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

borsAuto merge of #103046 - JanBeh:PR_clarify_cmp_terminology, r=workingjubilee3bcad65fbf6

master
1.0 KiB57 linesraw
1// check-pass
2// run-rustfix
3
4#![warn(unused_braces, unused_parens)]
5#![allow(unreachable_code, unused_unsafe)] // for rustfix
6
7fn consume<T>(_: T) {}
8
9fn main() {
10    let _ = 7;
11    //~^WARN unnecessary parentheses
12
13    // Do not emit a lint in these cases,
14    // as we have to be careful with
15    // `ref` patterns.
16    {
17        let _ = { 7 };
18
19        if let 7 = { 7 } { }
20
21        match { 7 } {
22            _ => (),
23        }
24    }
25
26    if true {
27        //~^ WARN unnecessary braces
28    }
29
30    while false {
31        //~^ WARN unnecessary braces
32    }
33
34    let _: [u8; 3];
35    //~^ WARN unnecessary braces
36
37    consume(7);
38    //~^ WARN unnecessary braces
39
40    // Do not emit lint for multiline blocks.
41    let _ = {
42        7
43    };
44
45    // Do not emit lint for unsafe blocks.
46    let _ = unsafe { 7 };
47
48    // Do not emit lint, as the `{` would then
49    // be parsed as part of the `return`.
50    if { return } {
51
52    }
53
54    // regression test for https://github.com/rust-lang/rust/issues/106899
55    return println!("!");
56    //~^ WARN unnecessary braces
57}