summaryrefslogtreecommitdiffstats
path: root/tests/ui/let-else/let-else-non-diverging.rs
blob: a5442dd82f028171868e7ca89c238f40f212f0c2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
fn main() {
    let Some(x) = Some(1) else { //~ ERROR does not diverge
        Some(2)
    };
    let Some(x) = Some(1) else { //~ ERROR does not diverge
        if 1 == 1 {
            panic!();
        }
    };
    let Some(x) = Some(1) else { Some(2) }; //~ ERROR does not diverge

    // Ensure that uninhabited types do not "diverge".
    // This might be relaxed in the future, but when it is,
    // it should be an explicitly wanted decision.
    let Some(x) = Some(1) else { foo::<Uninhabited>() }; //~ ERROR does not diverge
}

enum Uninhabited {}

fn foo<T>() -> T {
    panic!()
}