diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2021-12-03 06:24:12 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-12-03 06:24:12 +0100 |
| commit | 570dc70a2b518924384b9d2bbe6736b42b6b4d63 (patch) | |
| tree | cd63eebecbd078888261bf332ce336e99b6f3760 | |
| parent | 94cd0259f247c4cadb2942e8f6fe52ff9fc2422b (diff) | |
| parent | 34b75664ee01f4c19ee67480c5711b7300db5f41 (diff) | |
| download | rust-570dc70a2b518924384b9d2bbe6736b42b6b4d63.tar.gz rust-570dc70a2b518924384b9d2bbe6736b42b6b4d63.zip | |
Rollup merge of #90854 - sanxiyn:unsized-and-uninhabited, r=estebank
Type can be unsized and uninhabited Fix #88150.
| -rw-r--r-- | compiler/rustc_middle/src/ty/layout.rs | 2 | ||||
| -rw-r--r-- | src/test/ui/issues/issue-88150.rs | 21 |
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 57506bc6834..02811b2491c 100644 --- a/compiler/rustc_middle/src/ty/layout.rs +++ b/compiler/rustc_middle/src/ty/layout.rs @@ -533,7 +533,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(); +} |
