summaryrefslogtreecommitdiffstats
path: root/src/test/ui/expr/if/if-check-panic.rs
blob: 037cd427ccf368b9568a37be027d0a01b5a99788 (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
// run-fail
// error-pattern:Number is odd
// ignore-emscripten no processes

fn even(x: usize) -> bool {
    if x < 2 {
        return false;
    } else if x == 2 {
        return true;
    } else {
        return even(x - 2);
    }
}

fn foo(x: usize) {
    if even(x) {
        println!("{}", x);
    } else {
        panic!("Number is odd");
    }
}

fn main() {
    foo(3);
}