summaryrefslogtreecommitdiffstats
path: root/tests/ui/try-block/try-block-unused-delims.fixed
blob: 756081738c3d7403423d8bee9f97a493c0ea7fd1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// check-pass
// compile-flags: --edition 2018
// run-rustfix

#![feature(try_blocks)]
#![warn(unused_parens, unused_braces)]

fn consume<T>(_: Result<T, T>) -> T { todo!() }

fn main() {
    consume(try {});
    //~^ WARN unnecessary parentheses

    consume(try {});
    //~^ WARN unnecessary braces

    match try {} {
        //~^ WARN unnecessary parentheses
        Ok(()) | Err(()) => (),
    }

    if let Err(()) = try {} {}
    //~^ WARN unnecessary parentheses

    match try {} {
        //~^ WARN unnecessary parentheses
        Ok(()) | Err(()) => (),
    }
}