]> git.lizzy.rs Git - rust.git/blob - tests/ui/type-alias-impl-trait/closures_in_branches.rs
Auto merge of #106916 - lukas-code:overlapping-substs, r=estebank
[rust.git] / tests / ui / type-alias-impl-trait / closures_in_branches.rs
1 #![feature(type_alias_impl_trait)]
2
3 type Foo = impl std::ops::FnOnce(String) -> usize;
4
5 fn foo(b: bool) -> Foo {
6     if b {
7         |x| x.len() //~ ERROR type annotations needed
8     } else {
9         panic!()
10     }
11 }
12
13
14 type Foo1 = impl std::ops::FnOnce(String) -> usize;
15 fn foo1(b: bool) -> Foo1 {
16     |x| x.len()
17 }
18
19 fn bar(b: bool) -> impl std::ops::FnOnce(String) -> usize {
20     if b {
21         |x| x.len() //~ ERROR type annotations needed
22     } else {
23         panic!()
24     }
25 }
26
27 fn bar1(b: bool) -> impl std::ops::FnOnce(String) -> usize {
28     |x| x.len()
29 }
30
31 fn main() {}