Skip to content

Commit

Permalink
Type can be unsized and uninhabited
Browse files Browse the repository at this point in the history
  • Loading branch information
sanxiyn committed Nov 13, 2021
1 parent e90c5fb commit 34b7566
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/ty/layout.rs
Expand Up @@ -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;
}

Expand Down
21 changes: 21 additions & 0 deletions 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();
}

0 comments on commit 34b7566

Please sign in to comment.