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

Add some more specific checks to the MIR validator #125851

Merged
merged 1 commit into from
Jun 2, 2024

Conversation

scottmcm
Copy link
Member

@scottmcm scottmcm commented Jun 1, 2024

None of the PointerCoercions had any checks, so while there's probably more that could be done here, hopefully these are better than the previous nothing.

r? mir

@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 Jun 1, 2024
@rustbot
Copy link
Collaborator

rustbot commented Jun 1, 2024

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

);
}
CastKind::PointerCoercion(PointerCoercion::Unsize) => {
// FIXME: Add Checks for this
Copy link
Member Author

Choose a reason for hiding this comment

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

https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/adjustment/enum.PointerCoercion.html#variant.Unsize says "pointer/reference", but when I tried checking for that I got this ICE:

broken MIR in Item(DefId(0:4931 ~ core[d708]::cell::assert_coerce_unsized)) (after pass CheckPackedRef) at bb0[3]:
CastKind::PointerCoercion(Unsize) input must be a reference or raw pointer, not cell::UnsafeCell<&'{erased} i32>

so I just left it as FIXME since I don't know what the actual rule is (or if there's a bug).

Copy link
Member

Choose a reason for hiding this comment

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

this unsizes all CoerceUnsized types, so the documentation is wrong and you should leave this alone. Validating it would be checking that the trait T: CoerceUnsized<U> for the input and output types.

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.

r=me after amending the fixmes

);
}
CastKind::PointerCoercion(PointerCoercion::ClosureFnPointer(..)) => {
// FIXME: check safety & captures
Copy link
Member

Choose a reason for hiding this comment

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

and signature compatibility

);
}
CastKind::PointerCoercion(PointerCoercion::UnsafeFnPointer) => {
// FIXME: check safety
Copy link
Member

Choose a reason for hiding this comment

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

and signature compatibility

| CastKind::PointerExposeProvenance
| CastKind::PointerCoercion(_) => {}
CastKind::PointerWithExposedProvenance | CastKind::PointerExposeProvenance => {}
CastKind::PointerCoercion(PointerCoercion::ReifyFnPointer) => {
Copy link
Member

Choose a reason for hiding this comment

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

FIXME: should check signature compatibility

@rust-log-analyzer

This comment has been minimized.

None of the `PointerCoercion`s had any, so while there's probably more that could be done here, hopefully these are better than the previous nothing.
@scottmcm
Copy link
Member Author

scottmcm commented Jun 1, 2024

Did the requested updates, then rebased to fix conflicts.
@bors r=compiler-errors rollup

@bors
Copy link
Contributor

bors commented Jun 1, 2024

📌 Commit 11d6f18 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 Jun 1, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Jun 2, 2024
…kingjubilee

Rollup of 3 pull requests

Successful merges:

 - rust-lang#125311 (Make repr(packed) vectors work with SIMD intrinsics)
 - rust-lang#125849 (Migrate `run-make/emit-named-files` to `rmake.rs`)
 - rust-lang#125851 (Add some more specific checks to the MIR validator)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 30dc2ba into rust-lang:master Jun 2, 2024
6 checks passed
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Jun 2, 2024
Rollup merge of rust-lang#125851 - scottmcm:moar-validate, r=compiler-errors

Add some more specific checks to the MIR validator

None of the `PointerCoercion`s had any checks, so while there's probably more that could be done here, hopefully these are better than the previous nothing.

r? mir
@rustbot rustbot added this to the 1.80.0 milestone Jun 2, 2024
@scottmcm scottmcm deleted the moar-validate branch June 2, 2024 18:37
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.

6 participants