]> git.lizzy.rs Git - rust.git/blob - src/test/ui/lint/unused_braces.rs
Merge commit 'ff0993c5e9162ddaea78e83d0f0161e68bd4ea73' into clippy
[rust.git] / src / test / ui / lint / unused_braces.rs
1 // check-pass
2 #![warn(unused_braces, unused_parens)]
3
4 fn consume<T>(_: T) {}
5
6 fn main() {
7     let _ = (7);
8     //~^WARN unnecessary parentheses
9
10     // Do not emit a lint in these cases,
11     // as we have to be careful with
12     // `ref` patterns.
13     {
14         let _ = { 7 };
15
16         if let 7 = { 7 } { }
17
18         match { 7 } {
19             _ => (),
20         }
21     }
22
23     if { true } {
24         //~^ WARN unnecessary braces
25     }
26
27     while { false } {
28         //~^ WARN unnecessary braces
29     }
30
31     let _: [u8; { 3 }];
32     //~^ WARN unnecessary braces
33
34     consume({ 7 });
35     //~^ WARN unnecessary braces
36
37     // Do not emit lint for multiline blocks.
38     let _ = {
39         7
40     };
41
42     // Do not emit lint for unsafe blocks.
43     let _ = unsafe { 7 };
44
45     // Do not emit lint, as the `{` would then
46     // be parsed as part of the `return`.
47     if { return } {
48
49     }
50 }