about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--compiler/rustc_typeck/src/check/check.rs1
-rw-r--r--src/test/ui/typeck/issue-80207-unsized-return.rs20
2 files changed, 20 insertions, 1 deletions
diff --git a/compiler/rustc_typeck/src/check/check.rs b/compiler/rustc_typeck/src/check/check.rs
index 47361092a5c..9c8b09823e5 100644
--- a/compiler/rustc_typeck/src/check/check.rs
+++ b/compiler/rustc_typeck/src/check/check.rs
@@ -192,7 +192,6 @@ pub(super) fn check_fn<'a, 'tcx>(
         // possible cases.
         fcx.check_expr(&body.value);
         fcx.require_type_is_sized(declared_ret_ty, decl.output.span(), traits::SizedReturnType);
-        tcx.sess.delay_span_bug(decl.output.span(), "`!Sized` return type");
     } else {
         fcx.require_type_is_sized(declared_ret_ty, decl.output.span(), traits::SizedReturnType);
         fcx.check_return_expr(&body.value);
diff --git a/src/test/ui/typeck/issue-80207-unsized-return.rs b/src/test/ui/typeck/issue-80207-unsized-return.rs
new file mode 100644
index 00000000000..75430da1482
--- /dev/null
+++ b/src/test/ui/typeck/issue-80207-unsized-return.rs
@@ -0,0 +1,20 @@
+// check-pass
+
+trait Foo {
+    fn do_stuff() -> Self;
+}
+
+trait Bar {
+    type Output;
+}
+
+impl<T> Foo for dyn Bar<Output = T>
+where
+    Self: Sized,
+{
+    fn do_stuff() -> Self {
+        todo!()
+    }
+}
+
+fn main() {}