Add regression test for #80179
This commit is contained in:
parent
4f6be466fd
commit
5e6dc927f7
27
src/test/ui/fn/issue-80179.rs
Normal file
27
src/test/ui/fn/issue-80179.rs
Normal 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() {}
|
21
src/test/ui/fn/issue-80179.stderr
Normal file
21
src/test/ui/fn/issue-80179.stderr
Normal 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`.
|
Loading…
x
Reference in New Issue
Block a user