summaryrefslogtreecommitdiffstats
path: root/src/test/ui/try-block/try-block-type-error.rs
blob: fe1993a37f64aff266dea55af07e3de1fe491980 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// compile-flags: --edition 2018

#![feature(try_blocks)]

fn foo() -> Option<()> { Some(()) }

fn main() {
    let _: Option<f32> = try {
        foo()?;
        42
        //~^ ERROR type mismatch
    };

    let _: Option<i32> = try {
        foo()?;
    };
    //~^ ERROR type mismatch
}