File tree 2 files changed +48
-0
lines changed
2 files changed +48
-0
lines changed Original file line number Diff line number Diff line change
1
+ // Functions with a type placeholder `_` as the return type should
2
+ // show a function pointer suggestion when given a function item
3
+ // and suggest how to return closures correctly from a function.
4
+ // This is a regression test of #80179
5
+
6
+ fn returns_i32 ( ) -> i32 {
7
+ 0
8
+ }
9
+
10
+ fn returns_fn_ptr ( ) -> _ {
11
+ //~^ ERROR the type placeholder `_` is not allowed within types on item signatures [E0121]
12
+ //~| NOTE not allowed in type signatures
13
+ //~| HELP replace with the correct return type
14
+ //~| SUGGESTION fn() -> i32
15
+ returns_i32
16
+ }
17
+
18
+ fn returns_closure ( ) -> _ {
19
+ //~^ ERROR the type placeholder `_` is not allowed within types on item signatures [E0121]
20
+ //~| NOTE not allowed in type signatures
21
+ //~| HELP consider using an `Fn`, `FnMut`, or `FnOnce` trait bound
22
+ //~| NOTE for more information on `Fn` traits and closure types, see
23
+ // https://doc.rust-lang.org/book/ch13-01-closures.html
24
+ || 0
25
+ }
26
+
27
+ fn main ( ) { }
Original file line number Diff line number Diff line change
1
+ error[E0121]: the type placeholder `_` is not allowed within types on item signatures
2
+ --> $DIR/issue-80179.rs:10:24
3
+ |
4
+ LL | fn returns_fn_ptr() -> _ {
5
+ | ^
6
+ | |
7
+ | not allowed in type signatures
8
+ | help: replace with the correct return type: `fn() -> i32`
9
+
10
+ error[E0121]: the type placeholder `_` is not allowed within types on item signatures
11
+ --> $DIR/issue-80179.rs:18:25
12
+ |
13
+ LL | fn returns_closure() -> _ {
14
+ | ^ not allowed in type signatures
15
+ |
16
+ = help: consider using an `Fn`, `FnMut`, or `FnOnce` trait bound
17
+ = note: for more information on `Fn` traits and closure types, see https://doc.rust-lang.org/book/ch13-01-closures.html
18
+
19
+ error: aborting due to 2 previous errors
20
+
21
+ For more information about this error, try `rustc --explain E0121`.
You can’t perform that action at this time.
0 commit comments