2020-03-27 15:56:58 -05:00
|
|
|
// check-pass
|
2020-07-02 00:32:12 -05:00
|
|
|
// run-rustfix
|
|
|
|
|
2020-03-27 15:56:58 -05:00
|
|
|
#![warn(unused_braces, unused_parens)]
|
2020-07-02 00:32:12 -05:00
|
|
|
#![allow(unreachable_code, unused_unsafe)] // for rustfix
|
2020-03-27 15:56:58 -05:00
|
|
|
|
2020-04-04 15:40:31 -05:00
|
|
|
fn consume<T>(_: T) {}
|
|
|
|
|
2020-03-27 15:56:58 -05:00
|
|
|
fn main() {
|
|
|
|
let _ = (7);
|
|
|
|
//~^WARN unnecessary parentheses
|
|
|
|
|
2020-04-04 15:40:31 -05:00
|
|
|
// Do not emit a lint in these cases,
|
|
|
|
// as we have to be careful with
|
|
|
|
// `ref` patterns.
|
|
|
|
{
|
|
|
|
let _ = { 7 };
|
|
|
|
|
|
|
|
if let 7 = { 7 } { }
|
|
|
|
|
|
|
|
match { 7 } {
|
|
|
|
_ => (),
|
|
|
|
}
|
|
|
|
}
|
2020-03-27 15:56:58 -05:00
|
|
|
|
2020-04-04 15:40:31 -05:00
|
|
|
if { true } {
|
|
|
|
//~^ WARN unnecessary braces
|
|
|
|
}
|
|
|
|
|
|
|
|
while { false } {
|
2020-03-27 15:56:58 -05:00
|
|
|
//~^ WARN unnecessary braces
|
|
|
|
}
|
|
|
|
|
|
|
|
let _: [u8; { 3 }];
|
|
|
|
//~^ WARN unnecessary braces
|
|
|
|
|
2020-04-04 15:40:31 -05:00
|
|
|
consume({ 7 });
|
|
|
|
//~^ WARN unnecessary braces
|
|
|
|
|
|
|
|
// Do not emit lint for multiline blocks.
|
2020-03-27 15:56:58 -05:00
|
|
|
let _ = {
|
|
|
|
7
|
|
|
|
};
|
|
|
|
|
2020-04-04 15:40:31 -05:00
|
|
|
// Do not emit lint for unsafe blocks.
|
2020-03-27 15:56:58 -05:00
|
|
|
let _ = unsafe { 7 };
|
|
|
|
|
2020-04-04 15:40:31 -05:00
|
|
|
// Do not emit lint, as the `{` would then
|
2020-03-27 15:56:58 -05:00
|
|
|
// be parsed as part of the `return`.
|
|
|
|
if { return } {
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|