File tree 2 files changed +42
-0
lines changed
src/test/ui/type-alias-impl-trait
2 files changed +42
-0
lines changed Original file line number Diff line number Diff line change
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 number Diff line number Diff line change
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`.
You can’t perform that action at this time.
0 commit comments