summaryrefslogtreecommitdiffstats
path: root/tests/ui/expr/if/if-without-else-as-fn-expr.rs
blob: 19fbfb27ba6e97b9bc66f063d779e3a160b2a7e1 (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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
fn foo(bar: usize) -> usize {
    if bar % 5 == 0 {
        return 3;
    }
    //~^^^ ERROR `if` may be missing an `else` clause
}

fn foo2(bar: usize) -> usize {
    let x: usize = if bar % 5 == 0 {
        return 3;
    };
    //~^^^ ERROR `if` may be missing an `else` clause
    x
}

fn foo3(bar: usize) -> usize {
    if bar % 5 == 0 {
        3
    }
    //~^^^ ERROR `if` may be missing an `else` clause
}

fn foo_let(bar: usize) -> usize {
    if let 0 = 1 {
        return 3;
    }
    //~^^^ ERROR `if` may be missing an `else` clause
}

fn foo2_let(bar: usize) -> usize {
    let x: usize = if let 0 = 1 {
        return 3;
    };
    //~^^^ ERROR `if` may be missing an `else` clause
    x
}

fn foo3_let(bar: usize) -> usize {
    if let 0 = 1 {
        3
    }
    //~^^^ ERROR `if` may be missing an `else` clause
}

// FIXME(60254): deduplicate first error in favor of second.

fn main() {
    let _ = foo(1);
}