-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4f6be46
commit 5e6dc92
Showing
2 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Functions with a type placeholder `_` as the return type should | ||
// show a function pointer suggestion when given a function item | ||
// and suggest how to return closures correctly from a function. | ||
// This is a regression test of #80179 | ||
|
||
fn returns_i32() -> i32 { | ||
0 | ||
} | ||
|
||
fn returns_fn_ptr() -> _ { | ||
//~^ ERROR the type placeholder `_` is not allowed within types on item signatures [E0121] | ||
//~| NOTE not allowed in type signatures | ||
//~| HELP replace with the correct return type | ||
//~| SUGGESTION fn() -> i32 | ||
returns_i32 | ||
} | ||
|
||
fn returns_closure() -> _ { | ||
//~^ ERROR the type placeholder `_` is not allowed within types on item signatures [E0121] | ||
//~| NOTE not allowed in type signatures | ||
//~| HELP consider using an `Fn`, `FnMut`, or `FnOnce` trait bound | ||
//~| NOTE for more information on `Fn` traits and closure types, see | ||
// https://doc.rust-lang.org/book/ch13-01-closures.html | ||
|| 0 | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
error[E0121]: the type placeholder `_` is not allowed within types on item signatures | ||
--> $DIR/issue-80179.rs:10:24 | ||
| | ||
LL | fn returns_fn_ptr() -> _ { | ||
| ^ | ||
| | | ||
| not allowed in type signatures | ||
| help: replace with the correct return type: `fn() -> i32` | ||
|
||
error[E0121]: the type placeholder `_` is not allowed within types on item signatures | ||
--> $DIR/issue-80179.rs:18:25 | ||
| | ||
LL | fn returns_closure() -> _ { | ||
| ^ not allowed in type signatures | ||
| | ||
= help: consider using an `Fn`, `FnMut`, or `FnOnce` trait bound | ||
= note: for more information on `Fn` traits and closure types, see https://doc.rust-lang.org/book/ch13-01-closures.html | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0121`. |