summaryrefslogtreecommitdiffstats
path: root/tests/ui/fn/issue-80179.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:13 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:13 +0000
commit218caa410aa38c29984be31a5229b9fa717560ee (patch)
treec54bd55eeb6e4c508940a30e94c0032fbd45d677 /tests/ui/fn/issue-80179.rs
parentReleasing progress-linux version 1.67.1+dfsg1-1~progress7.99u1. (diff)
downloadrustc-218caa410aa38c29984be31a5229b9fa717560ee.tar.xz
rustc-218caa410aa38c29984be31a5229b9fa717560ee.zip
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/fn/issue-80179.rs')
-rw-r--r--tests/ui/fn/issue-80179.rs27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/ui/fn/issue-80179.rs b/tests/ui/fn/issue-80179.rs
new file mode 100644
index 000000000..35e39bebb
--- /dev/null
+++ b/tests/ui/fn/issue-80179.rs
@@ -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 placeholder `_` is not allowed within types on item signatures for return types [E0121]
+//~| NOTE not allowed in type signatures
+//~| HELP replace with the correct return type
+//~| SUGGESTION fn() -> i32
+ returns_i32
+}
+
+fn returns_closure() -> _ {
+//~^ ERROR the placeholder `_` is not allowed within types on item signatures for return types [E0121]
+//~| NOTE not allowed in type signatures
+//~| HELP replace with an appropriate return type
+//~| SUGGESTION impl Fn() -> i32
+//~| NOTE for more information on `Fn` traits and closure types
+ || 0
+}
+
+fn main() {}