summaryrefslogtreecommitdiffstats
path: root/tests/ui/type-alias-impl-trait/closures_in_branches.rs
blob: 7bb490bbec8183912429093fb2305a932857f131 (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
#![feature(type_alias_impl_trait)]

type Foo = impl std::ops::FnOnce(String) -> usize;

fn foo(b: bool) -> Foo {
    if b {
        |x| x.len() //~ ERROR type annotations needed
    } else {
        panic!()
    }
}


type Foo1 = impl std::ops::FnOnce(String) -> usize;
fn foo1(b: bool) -> Foo1 {
    |x| x.len()
}

fn bar(b: bool) -> impl std::ops::FnOnce(String) -> usize {
    if b {
        |x| x.len() //~ ERROR type annotations needed
    } else {
        panic!()
    }
}

fn bar1(b: bool) -> impl std::ops::FnOnce(String) -> usize {
    |x| x.len()
}

fn main() {}