Skip to content
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

Merged
merged 1 commit into from
Jul 15, 2021

Conversation

tmiasko
Copy link
Contributor

@tmiasko tmiasko commented Mar 20, 2021

Fixes #83107.

@rust-highfive
Copy link
Collaborator

r? @estebank

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 20, 2021
@JohnCSimon JohnCSimon added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 4, 2021
@camelid camelid added A-diagnostics Area: Messages for errors, warnings, and lints A-layout Area: Memory layout of types labels Apr 23, 2021
@JohnCSimon JohnCSimon added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 9, 2021
@camelid camelid added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 28, 2021
@@ -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));
Copy link
Member

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?

Copy link
Contributor Author

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).

@JohnCSimon JohnCSimon added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 14, 2021
@jackh726
Copy link
Member

jackh726 commented Jul 2, 2021

r? @jackh726

@bors r+

@rust-highfive rust-highfive assigned jackh726 and unassigned estebank Jul 2, 2021
@tmiasko tmiasko closed this Jul 15, 2021
@tmiasko tmiasko reopened this Jul 15, 2021
@jackh726
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Jul 15, 2021

📌 Commit d49f977 has been approved by jackh726

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 15, 2021
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Jul 15, 2021
Layout error instead of an ICE for packed and aligned types

Fixes rust-lang#83107.
@bors
Copy link
Contributor

bors commented Jul 15, 2021

⌛ Testing commit d49f977 with merge b1f8e27...

@bors
Copy link
Contributor

bors commented Jul 15, 2021

☀️ Test successful - checks-actions
Approved by: jackh726
Pushing b1f8e27 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jul 15, 2021
@bors bors merged commit b1f8e27 into rust-lang:master Jul 15, 2021
@rustbot rustbot added this to the 1.55.0 milestone Jul 15, 2021
@tmiasko tmiasko deleted the packed-aligned branch July 16, 2021 02:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-layout Area: Memory layout of types merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rustc panicked struct cannot be packed and aligned
8 participants