Skip to content

Commit

Permalink
Add regression test for #80179
Browse files Browse the repository at this point in the history
  • Loading branch information
ThePuzzlemaker committed Dec 22, 2020
1 parent 4f6be46 commit 5e6dc92
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/test/ui/fn/issue-80179.rs
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() {}
21 changes: 21 additions & 0 deletions src/test/ui/fn/issue-80179.stderr
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`.

0 comments on commit 5e6dc92

Please sign in to comment.