about summary refs log tree commit diff
diff options
context:
space:
mode:
authorSeo Sanghyeon <sanxiyn@gmail.com>2021-11-13 15:06:22 +0900
committerSeo Sanghyeon <sanxiyn@gmail.com>2021-11-13 15:06:22 +0900
commit34b75664ee01f4c19ee67480c5711b7300db5f41 (patch)
tree8d9ffb5f6d9e5eee9dbb2c49e4ab80f9fa5d0bf4
parente90c5fbbc5df5c81267747daeb937d4e955ce6ad (diff)
downloadrust-34b75664ee01f4c19ee67480c5711b7300db5f41.tar.gz
rust-34b75664ee01f4c19ee67480c5711b7300db5f41.zip
Type can be unsized and uninhabited
-rw-r--r--compiler/rustc_middle/src/ty/layout.rs2
-rw-r--r--src/test/ui/issues/issue-88150.rs21
2 files changed, 22 insertions, 1 deletions
diff --git a/compiler/rustc_middle/src/ty/layout.rs b/compiler/rustc_middle/src/ty/layout.rs
index b87e23af72b..a8dec82c883 100644
--- a/compiler/rustc_middle/src/ty/layout.rs
+++ b/compiler/rustc_middle/src/ty/layout.rs
@@ -512,7 +512,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
             }
         }
 
-        if sized && fields.iter().any(|f| f.abi.is_uninhabited()) {
+        if fields.iter().any(|f| f.abi.is_uninhabited()) {
             abi = Abi::Uninhabited;
         }
 
diff --git a/src/test/ui/issues/issue-88150.rs b/src/test/ui/issues/issue-88150.rs
new file mode 100644
index 00000000000..555a38637a4
--- /dev/null
+++ b/src/test/ui/issues/issue-88150.rs
@@ -0,0 +1,21 @@
+// run-pass
+// compile-flags:-C debuginfo=2
+// edition:2018
+
+use core::marker::PhantomData;
+
+pub struct Foo<T: ?Sized, A>(
+    PhantomData<(A, T)>,
+);
+
+enum Never {}
+
+impl<T: ?Sized> Foo<T, Never> {
+    fn new_foo() -> Foo<T, Never> {
+        Foo(PhantomData)
+    }
+}
+
+fn main() {
+    let _ = Foo::<[()], Never>::new_foo();
+}