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

Pass the right ParamEnv to might_permit_raw_init_strict #128720

Merged
merged 1 commit into from
Aug 7, 2024

Conversation

y21
Copy link
Member

@y21 y21 commented Aug 6, 2024

Fixes #119620

might_permit_raw_init_strict currently passes an empty ParamEnv to the InterpCx, instead of the actual ParamEnv that was passed in to check_validity_requirement at callsite.

This leads to ICEs such as the linked issue where for UnsafeCell<*mut T> we initially get the layout with the right ParamEnv (which suceeds because it can prove that T: Sized and therefore UnsafeCell<*mut T> has a known layout) but then do the rest with an empty ParamEnv where T: Sized is not known to hold so getting the layout for *mut T later fails.

This runs into an assertion in other layout code where it's making the (valid) assumption that, when we already have a layout for a struct (UnsafeCell<*mut T>), getting the layout of one of its fields (*mut T) should also succeed, which wasn't the case here due to using the wrong ParamEnv.

So, this PR changes it to just use the same ParamEnv all the way throughout.

@rustbot
Copy link
Collaborator

rustbot commented Aug 6, 2024

r? @petrochenkov

rustbot has assigned @petrochenkov.
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 the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 6, 2024
@rustbot
Copy link
Collaborator

rustbot commented Aug 6, 2024

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Aug 6, 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.

Makes sense to me.

@compiler-errors
Copy link
Member

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Aug 6, 2024

📌 Commit fdf3b31 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 Aug 6, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 6, 2024
…iaskrgr

Rollup of 7 pull requests

Successful merges:

 - rust-lang#128369 (rustc_lint: make `let-underscore-lock` translatable)
 - rust-lang#128377 (Fix ICE Caused by Incorrectly Delaying E0107)
 - rust-lang#128517 (Fallback to string formatting if source is not available for lint)
 - rust-lang#128685 (Remove the root Cargo.lock from the rust-src component)
 - rust-lang#128693 (rustdoc-search: account for numeric disambiguators on impls)
 - rust-lang#128720 (Pass the right `ParamEnv` to `might_permit_raw_init_strict`)
 - rust-lang#128736 (Fix rustdoc missing handling of remap-path-prefix option)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 8912318 into rust-lang:master Aug 7, 2024
6 checks passed
@rustbot rustbot added this to the 1.82.0 milestone Aug 7, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Aug 7, 2024
Rollup merge of rust-lang#128720 - y21:issue119620, r=compiler-errors

Pass the right `ParamEnv` to `might_permit_raw_init_strict`

Fixes rust-lang#119620

`might_permit_raw_init_strict` currently passes an empty `ParamEnv` to the `InterpCx`, instead of the actual `ParamEnv` that was passed in to `check_validity_requirement` at callsite.

This leads to ICEs such as the linked issue where for `UnsafeCell<*mut T>` we initially get the layout with the right `ParamEnv` (which suceeds because it can prove that `T: Sized` and therefore `UnsafeCell<*mut T>` has a known layout) but then do the rest with an empty `ParamEnv` where `T: Sized` is not known to hold so getting the layout for `*mut T` later fails.

This runs into an assertion in other layout code where it's making the (valid) assumption that, when we already have a layout for a struct (`UnsafeCell<*mut T>`), getting the layout of one of its fields (`*mut T`) should also succeed, which wasn't the case here due to using the wrong `ParamEnv`.

So, this PR changes it to just use the same `ParamEnv` all the way throughout.
bors added a commit to rust-lang/rust-clippy that referenced this pull request Aug 8, 2024
Rustup

r? `@ghost`

changelog: ICE fix [`uninit_vec`] through rust-lang/rust#128720
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.

check_validity_requirement (called from clippy) throws an ICE for std::cell::UnsafeCell
5 participants