summaryrefslogtreecommitdiffstats
path: root/src/tools/rustfmt/tests/target/try_block.rs
blob: 19a3f3e1487698bcee7151f86ddb293693e618bc (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
// rustfmt-edition: 2018

fn main() -> Result<(), !> {
    let _x: Option<_> = try { 4 };

    try {}
}

fn baz() -> Option<i32> {
    if (1 == 1) {
        return try { 5 };
    }

    // test
    let x: Option<()> = try {
        // try blocks are great
    };

    let y: Option<i32> = try { 6 }; // comment

    let x: Option<i32> = try {
        baz()?;
        baz()?;
        baz()?;
        7
    };

    return None;
}