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

Correctly account for niche-optimized tags in rustc_transmute #130371

Merged
merged 2 commits into from
Sep 15, 2024

Conversation

saethlin
Copy link
Member

@saethlin saethlin commented Sep 14, 2024

This is a bit hacky, but it fixes the ICE and makes it possible to run the safe transmute check on every mem::transmute check we instantiate. I want to write a lint that needs to do that, but this stands well on its own.

cc @jswrenn here's the fix I alluded to yesterday :)

Fixes #123693

@rustbot
Copy link
Collaborator

rustbot commented Sep 14, 2024

r? @BoxyUwU

rustbot has assigned @BoxyUwU.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Sep 14, 2024
Copy link
Member

@compiler-errors compiler-errors left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@@ -359,7 +365,7 @@ pub(crate) mod rustc {
let variants = def.discriminants(cx.tcx()).try_fold(
Self::uninhabited(),
|variants, (idx, ref discriminant)| {
let variant = layout_of_variant(idx)?;
let variant = layout_of_variant(idx, Some(tag_encoding.clone()))?;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the fact that RangeInclusive is not Copy is criminal tbh

@compiler-errors
Copy link
Member

r=me when green

@saethlin
Copy link
Member Author

@bors r=compiler-errors

@bors
Copy link
Contributor

bors commented Sep 15, 2024

📌 Commit 2ac554b has been approved by compiler-errors

It is now in the queue for this repository.

@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 Sep 15, 2024
@jswrenn
Copy link
Member

jswrenn commented Sep 15, 2024

Tremendous thanks for this @saethlin!!!

@jswrenn
Copy link
Member

jswrenn commented Sep 15, 2024

makes it possible to run the safe transmute check on every mem::transmute check we instantiate

Please keep me posted about this experiment! It sounds like a great way to burn down ICEs in rustc_transmute, at the very least.

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Sep 15, 2024
… r=compiler-errors

Correctly account for niche-optimized tags in rustc_transmute

This is a bit hacky, but it fixes the ICE and makes it possible to run the safe transmute check on every `mem::transmute` check we instantiate. I want to write a lint that needs to do that, but this stands well on its own.

cc `@jswrenn` here's the fix I alluded to yesterday :)

Fixes rust-lang#123693
workingjubilee added a commit to workingjubilee/rustc that referenced this pull request Sep 15, 2024
… r=compiler-errors

Correctly account for niche-optimized tags in rustc_transmute

This is a bit hacky, but it fixes the ICE and makes it possible to run the safe transmute check on every `mem::transmute` check we instantiate. I want to write a lint that needs to do that, but this stands well on its own.

cc `@jswrenn` here's the fix I alluded to yesterday :)

Fixes rust-lang#123693
workingjubilee added a commit to workingjubilee/rustc that referenced this pull request Sep 15, 2024
… r=compiler-errors

Correctly account for niche-optimized tags in rustc_transmute

This is a bit hacky, but it fixes the ICE and makes it possible to run the safe transmute check on every `mem::transmute` check we instantiate. I want to write a lint that needs to do that, but this stands well on its own.

cc ``@jswrenn`` here's the fix I alluded to yesterday :)

Fixes rust-lang#123693
bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 15, 2024
…kingjubilee

Rollup of 3 pull requests

Successful merges:

 - rust-lang#130295 (Fix target-cpu fpu features on Armv8-R.)
 - rust-lang#130325 (Use -0.0 in `intrinsics::simd::reduce_add_unordered`)
 - rust-lang#130371 (Correctly account for niche-optimized tags in rustc_transmute)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 15, 2024
…iaskrgr

Rollup of 5 pull requests

Successful merges:

 - rust-lang#129195 (Stabilize `&mut` (and `*mut`) as well as `&Cell` (and `*const Cell`) in const)
 - rust-lang#130118 (move Option::unwrap_unchecked into const_option feature gate)
 - rust-lang#130295 (Fix target-cpu fpu features on Armv8-R.)
 - rust-lang#130371 (Correctly account for niche-optimized tags in rustc_transmute)
 - rust-lang#130381 (library: Compute Rust exception class from its string repr)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 9ed667f into rust-lang:master Sep 15, 2024
6 checks passed
@rustbot rustbot added this to the 1.83.0 milestone Sep 15, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Sep 15, 2024
Rollup merge of rust-lang#130371 - saethlin:transmutability-enum-ice, r=compiler-errors

Correctly account for niche-optimized tags in rustc_transmute

This is a bit hacky, but it fixes the ICE and makes it possible to run the safe transmute check on every `mem::transmute` check we instantiate. I want to write a lint that needs to do that, but this stands well on its own.

cc `@jswrenn` here's the fix I alluded to yesterday :)

Fixes rust-lang#123693
@saethlin saethlin deleted the transmutability-enum-ice branch September 15, 2024 14:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ICE: Size::sub: 0 - 1 would result in negative size
6 participants