-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Conversation
Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt |
); | ||
} | ||
CastKind::PointerCoercion(PointerCoercion::Unsize) => { | ||
// FIXME: Add Checks for this |
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.
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).
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 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.
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.
r=me after amending the fixmes
); | ||
} | ||
CastKind::PointerCoercion(PointerCoercion::ClosureFnPointer(..)) => { | ||
// FIXME: check safety & captures |
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.
and signature compatibility
); | ||
} | ||
CastKind::PointerCoercion(PointerCoercion::UnsafeFnPointer) => { | ||
// FIXME: check safety |
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.
and signature compatibility
| CastKind::PointerExposeProvenance | ||
| CastKind::PointerCoercion(_) => {} | ||
CastKind::PointerWithExposedProvenance | CastKind::PointerExposeProvenance => {} | ||
CastKind::PointerCoercion(PointerCoercion::ReifyFnPointer) => { |
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.
FIXME: should check signature compatibility
This comment has been minimized.
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.
Did the requested updates, then rebased to fix conflicts. |
…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
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
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