Skip to content

Less conservative uninhabitedness check #54125

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 23 commits into from
Dec 21, 2018
Merged
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
62b3590
Check for uninhabitedness instead of never
varkor Sep 11, 2018
88afbf2
Make uninhabitedness checking more intelligent
varkor Sep 11, 2018
ffce4fb
Update uninhabited matches tests
varkor Sep 11, 2018
64c2a31
Address comments
varkor Sep 14, 2018
9f609f9
Fix Ref inhabitedness comment
varkor Sep 20, 2018
4c88be3
Fix handling of divergent dicriminants
varkor Oct 16, 2018
419d2d8
Update const eval uninhabited messages
varkor Oct 16, 2018
d065a49
Nonempty arrays of uninhabited arrays are Abi::Uninhabited
varkor Oct 16, 2018
51e1c64
conservative_is_uninhabited implies abi.is_uninhabited
varkor Oct 16, 2018
6e5e54f
Use unions for uninhabitedness checking rather than mem::transmute
varkor Oct 18, 2018
a38ff37
Improve `conservative_is_uninhabited` comment
varkor Oct 19, 2018
13af92f
Add note on nonzero-sized uninhabited types
varkor Oct 23, 2018
9c66599
Address unused variables warning with TcpStream
varkor Oct 24, 2018
cb4bd5a
Update ub-uninhabit tests
varkor Nov 3, 2018
20415af
Add privately uninhabited dead code test
varkor Nov 3, 2018
210e234
Make liveness analysis respect privacy
varkor Nov 6, 2018
4d8a6ea
Fix some misbehaving tests
varkor Nov 6, 2018
6561732
Consider privacy in more locations
varkor Nov 20, 2018
3dd5034
Restore old match behaviour
varkor Nov 20, 2018
19ea2d1
Add a mir-opt test
varkor Dec 11, 2018
573c1ff
Add a FIXME for mir build unreachable destination checking
varkor Dec 11, 2018
2ba3e66
Update tests
varkor Dec 11, 2018
0a8b696
Remove nil-enum test
varkor Dec 20, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/librustc/ty/layout.rs
Original file line number Diff line number Diff line change
@@ -551,13 +551,19 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
let size = element.size.checked_mul(count, dl)
.ok_or(LayoutError::SizeOverflow(ty))?;

let abi = if size != Size::ZERO && ty.conservative_is_uninhabited(tcx) {
Abi::Uninhabited
} else {
Abi::Aggregate { sized: true }
};

tcx.intern_layout(LayoutDetails {
variants: Variants::Single { index: VariantIdx::new(0) },
fields: FieldPlacement::Array {
stride: element.size,
count
},
abi: Abi::Aggregate { sized: true },
abi,
align: element.align,
size
})