Add regression test for #80179

This commit is contained in:
ThePuzzlemaker 2020-12-22 13:25:37 -06:00
parent 4f6be466fd
commit 5e6dc927f7
No known key found for this signature in database
GPG Key ID: 968CD9D71C9FBB6C
2 changed files with 48 additions and 0 deletions

View File

@ -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() {}

View File

@ -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`.