-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Layout error instead of an ICE for packed and aligned types #83319
Conversation
r? @estebank (rust-highfive has picked a reviewer for you, use r? to override) |
@@ -311,7 +311,8 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> { | |||
let dl = self.data_layout(); | |||
let pack = repr.pack; | |||
if pack.is_some() && repr.align.is_some() { | |||
bug!("struct cannot be packed and aligned"); | |||
self.tcx.sess.delay_span_bug(DUMMY_SP, "struct cannot be packed and aligned"); | |||
return Err(LayoutError::Unknown(ty)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it correct for this and below to return LayoutError::Unknown
? Is the idea that it doesn't matter because an error will have already been emitted and the Unknown
will never be emitted to the user?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Conceptually returning LayoutError::Unknown
does seems correct to me. At the same time it wouldn't be exactly the kind of error we would like to emit, given that it is relatively uninformative.
The general idea is that the incorrect use of packed & aligned will diagnosed elsewhere, before we reach any code that is in position to assume that failure to compute layout is an error or a bug (like codegen does assume).
@bors r+ |
📌 Commit d49f977 has been approved by |
Layout error instead of an ICE for packed and aligned types Fixes rust-lang#83107.
☀️ Test successful - checks-actions |
Fixes #83107.