-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
ICE with uninhabited and dynamically sized types #82954
Comments
Slightly smaller: use std::marker::PhantomData;
pub enum Empty {}
fn main() {
let _x: PhantomData<(Empty, [usize])>;
} |
Bisected:
|
Assigning @rustbot label -I-prioritize +P-medium |
#54125 looks like it's the relevant PR, but it's not actually a bug, it just extends the checks to more items. I don't think this is really a regression, the bug was always there (only the ICE is a regression). |
Issue: rust-lang/rust#82954
A struct layout is uninhabited only if it sized and has any uninhabited fields (since #50622). This creates discrepancy with type-level view of things. rust/compiler/rustc_middle/src/ty/layout.rs Lines 481 to 483 in 61edfd5
|
Fixed by #90854 |
Code
Playground
Error output
The error seems to only occur when using an uninhabited type with a dynamically sized one in a tuple.
Inhabited types with dynamically sized and uninhabited types with sized types both work.
A simple workaround for now is to box the DST in the PhantomData.
The text was updated successfully, but these errors were encountered: