-
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
MIR validation: reject in-place argument/return for packed fields #115164
Conversation
r? @b-naber (rustbot has picked a reviewer for you, use r? to override) |
36e3782
to
c3dd437
Compare
let mut has_duplicates = false; | ||
for arg in args { | ||
if let Operand::Move(place) = arg { | ||
has_duplicates |= !self.place_cache.insert(place.as_ref()); | ||
if is_within_packed(self.tcx, &self.body.local_decls, *place).is_some() { |
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.
@cjgillot right now this is more strict than your check in #115138. Your pass might introduce move of packed fields if the field happens to not require more alignment anyway (such as a u8
in a packed struct). However determining that requires a param_env
and then I'd have to move this check into the TypeChecker
... is it really worth allowing such moves?
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.
My patch uses is_disaligned
for simplicity. No objection to using is_with_packed
: as simple and more secure.
c3dd437
to
739144f
Compare
@bors r+ rollup |
…iaskrgr Rollup of 8 pull requests Successful merges: - rust-lang#115164 (MIR validation: reject in-place argument/return for packed fields) - rust-lang#115240 (codegen_llvm/llvm_type: avoid matching on the Rust type) - rust-lang#115294 (More precisely detect cycle errors from type_of on opaque) - rust-lang#115310 (Document panic behavior across editions, and improve xrefs) - rust-lang#115311 (Revert "Suggest using `Arc` on `!Send`/`!Sync` types") - rust-lang#115317 (Devacationize oli-obk) - rust-lang#115319 (don't use SnapshotVec in Graph implementation, as it looks unused; use Vec instead) - rust-lang#115322 (Tweak output of `to_pretty_impl_header` involving only anon lifetimes) r? `@ghost` `@rustbot` modify labels: rollup
As discussed here.