summaryrefslogtreecommitdiffstats
path: root/tests/ui/match/non-first-arm-doesnt-match-expected-return-type.rs
blob: 85b1ef7555edcbe31c96a84c917266b1c34ffe34 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#![allow(unused)]

fn test(shouldwe: Option<u32>, shouldwe2: Option<u32>) -> u32 {
    //~^ NOTE expected `u32` because of return type
    match shouldwe {
        Some(val) => {
            match shouldwe2 {
                Some(val) => {
                    return val;
                }
                None => (), //~ ERROR mismatched types
                //~^ NOTE expected `u32`, found `()`
            }
        }
        None => return 12,
    }
}

fn main() {
    println!("returned {}", test(None, Some(5)));
}