summaryrefslogtreecommitdiffstats
path: root/tests/ui/inference/question-mark-type-infer.rs
blob: 10560f85ed480a67d4012043c9e2f7b6504c28ea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// Test that type inference fails where there are multiple possible return types
// for the `?` operator.

fn f(x: &i32) -> Result<i32, ()> {
    Ok(*x)
}

fn g() -> Result<Vec<i32>, ()> {
    let l = [1, 2, 3, 4];
    l.iter().map(f).collect()?
    //~^ ERROR type annotations needed
}

fn main() {
    g();
}