-
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
compiler: Error on layout of enums with invalid reprs #131843
Conversation
This comment has been minimized.
This comment has been minimized.
rust-analyzer is developed in its own repository. If possible, consider making this change to rust-lang/rust-analyzer instead. cc @rust-lang/rust-analyzer |
a3cd353
to
a5338f7
Compare
This comment has been minimized.
This comment has been minimized.
a5338f7
to
dbf0719
Compare
No idea why my brain insisted it wasn't fully imported. |
This comment has been minimized.
This comment has been minimized.
huh, I thought |
dbf0719
to
382a3f8
Compare
oddly I'll take it, I guess! |
compiler/rustc_abi/src/layout.rs
Outdated
@@ -39,7 +39,7 @@ enum NicheBias { | |||
End, | |||
} | |||
|
|||
#[derive(Copy, Clone, Debug)] | |||
#[derive(Copy, Clone, Debug, PartialEq, Eq)] |
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.
I think rust-analyzer's derives of these are probably unnecessary but I'm not gonna fight that war today.
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.
I think they're needed because we put the Result<Arc<Layout>, LayoutError>
s into a salsa
database.
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.
Huh, interesting.
Yeah, the r-a test suite doesn't get run (and probably doesn't pass, I think there were some issues on i386). |
This comment has been minimized.
This comment has been minimized.
382a3f8
to
f090e48
Compare
This comment has been minimized.
This comment has been minimized.
|
5a9c4dd
to
12ce35a
Compare
Hm I feel like this should go to |
r-a isn't setup as a test step in boopstrap, it is setup as a build step |
ah, is it finally time to promote it to its own directory? |
compiler/rustc_abi/src/layout.rs
Outdated
assert_eq!( | ||
common_align, field.align.abi, | ||
"non-Aggregate field with matching ABI but differing alignment" | ||
); |
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.
This assert is similar to the one in the sanity check: Hitting it means that an invalid layout was already created elsewhere.
Instead of trying to make the consumers of layouts work with invalid layouts, I think we should find the place where the invalid layouts are created to begin with and emit the LayoutCalculatorError::ReprConflict
there.
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.
Philosophical discussion about the meaning of ICEs aside, that does result in a much smaller fix. I feel a bit silly for heading down that path as far as I did. Thanks!
12ce35a
to
b3c1d23
Compare
b3c1d23
to
9f4c915
Compare
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.
Thanks!
@bors r+ rollup |
…iaskrgr Rollup of 9 pull requests Successful merges: - rust-lang#121560 (Allow `#[deny]` inside `#[forbid]` as a no-op) - rust-lang#131365 (Fix missing rustfmt in msi installer rust-lang#101993) - rust-lang#131647 (Register `src/tools/unicode-table-generator` as a runnable tool) - rust-lang#131843 (compiler: Error on layout of enums with invalid reprs) - rust-lang#131926 (Align boolean option descriptions in `configure.py`) - rust-lang#131961 (compiletest: tidy up how `tidy` and `tidy` (html version) are disambiguated) - rust-lang#131962 (Make `llvm::set_section` take a `&CStr`) - rust-lang#131964 (add latest crash tests) - rust-lang#131965 (remove outdated comment) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#131843 - workingjubilee:thaw-impossible-reprs, r=lukas-code compiler: Error on layout of enums with invalid reprs Surprising no one, the ICEs with the same message have the same root cause. Invalid reprs can reach layout computation for various reasons. For instance, the compiler may want to use its layout computations to discern if a combination of layout-affecting attributes results in a valid type to begin with by e.g. computing its size. When the input is bad, return an error reflecting that the answer to the question is not a useful one.
Surprising no one, the ICEs with the same message have the same root cause.
Invalid reprs can reach layout computation for various reasons. For instance, the compiler may want to use its layout computations to discern if a combination of layout-affecting attributes results in a valid type to begin with by e.g. computing its size. When the input is bad, return an error reflecting that the answer to the question is not a useful one.
non-Aggregate field with matching ABI but differing alignment
#126966non-Aggregate field with matching ABI but differing alignment
#128870