Skip to content

Commit 5d39418

Browse files
committed
Add some tests showcasing further differences between TAIT and RPIT
1 parent 8829643 commit 5d39418

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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()
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() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
error[E0282]: type annotations needed
2+
--> $DIR/closures_in_branches.rs:21:10
3+
|
4+
LL | |x| x.len()
5+
| ^ consider giving this closure parameter a type
6+
|
7+
= note: type must be known at this point
8+
9+
error: aborting due to previous error
10+
11+
For more information about this error, try `rustc --explain E0282`.

0 commit comments

Comments
 (0)