about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2022-11-17 22:33:21 +0100
committerGitHub <noreply@github.com>2022-11-17 22:33:21 +0100
commit43fa2918d1e4dfd90f83ce46aac8373ae8120068 (patch)
tree450ccfac1cd4b1b2c6a8224466d104984702229a /src
parent68a8109ddbb44fdfdd455036d2e53a8bf3545d4e (diff)
parent75afb22331daececeba38a3efb0134348d6c14d9 (diff)
downloadrust-43fa2918d1e4dfd90f83ce46aac8373ae8120068.tar.gz
rust-43fa2918d1e4dfd90f83ce46aac8373ae8120068.zip
Rollup merge of #104508 - compiler-errors:dyn-return, r=oli-obk
Check `dyn*` return type correctly

In `check_fn`, if the declared return type is `dyn Trait`, then we check the return type separately to produce better diagnostics, because this is never valid -- however, when `dyn*` was introduced, this check was never adjusted to only account for *unsized* `dyn Trait` and not *sized* `dyn* Trait`.

Fixes #104501
Diffstat (limited to 'src')
-rw-r--r--src/test/ui/dyn-star/return.rs10
-rw-r--r--src/test/ui/dyn-star/return.stderr11
2 files changed, 21 insertions, 0 deletions
diff --git a/src/test/ui/dyn-star/return.rs b/src/test/ui/dyn-star/return.rs
new file mode 100644
index 00000000000..fa3d8d7d506
--- /dev/null
+++ b/src/test/ui/dyn-star/return.rs
@@ -0,0 +1,10 @@
+// check-pass
+
+#![feature(dyn_star)]
+//~^ WARN the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes
+
+fn _foo() -> dyn* Unpin {
+    4usize
+}
+
+fn main() {}
diff --git a/src/test/ui/dyn-star/return.stderr b/src/test/ui/dyn-star/return.stderr
new file mode 100644
index 00000000000..e000351a68f
--- /dev/null
+++ b/src/test/ui/dyn-star/return.stderr
@@ -0,0 +1,11 @@
+warning: the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes
+  --> $DIR/return.rs:3:12
+   |
+LL | #![feature(dyn_star)]
+   |            ^^^^^^^^
+   |
+   = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
+   = note: `#[warn(incomplete_features)]` on by default
+
+warning: 1 warning emitted
+