-
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
Remove both StorageLive and StorageDead in CopyProp. #107524
Conversation
r? @davidtwco (rustbot has picked a reviewer for you, use r? to override) |
Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt |
6f0cb3c
to
4630aef
Compare
cc @RalfJung |
Thanks for the quick fix!
Ah, I see. Makes sense. |
I'm afraid I can't review that part, I don't know the APIs it uses so I don't even know what it actually checks. So either r=me with that part moved to a separate PR, or we wait for another reviewer. |
4630aef
to
3c10cf0
Compare
sum += a[i]; | ||
} | ||
|
||
let _ = sum; |
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.
let _val = sum
might be better, _
patterns can be quite surprising...
I don't really have an opinion on whether this should be UB. This is not a (currently) difficult invariant to preserve, so optimizations should probably preserve it. |
@bors r+ |
⌛ Testing commit e8ac040 with merge 9fcf4e35c49a654a7cbdfaf59a2e5d8882938b9b... |
💔 Test failed - checks-actions |
@bors retry CI was broken |
@bors retry |
Remove both StorageLive and StorageDead in CopyProp. Fixes rust-lang#107511 rust-lang#106908 removed StorageDead without the accompanying StorageLive. In loops, execution would see repeated StorageLive, without any StorageDead, which is UB. So when removing storage statements, we have to remove both StorageLive and StorageDead. ~I also added a MIR validation pass for StorageLive. It may be a bit overzealous.~
…iaskrgr Rollup of 7 pull requests Successful merges: - rust-lang#106919 (Recover `_` as `..` in field pattern) - rust-lang#107493 (Improve diagnostic for missing space in range pattern) - rust-lang#107515 (Improve pretty-printing of `HirIdValidator` errors) - rust-lang#107524 (Remove both StorageLive and StorageDead in CopyProp.) - rust-lang#107532 (Erase regions before doing uninhabited check in borrowck) - rust-lang#107559 (Rename `rust_2015` → `is_rust_2015`) - rust-lang#107577 (Reinstate the `hir-stats.rs` tests on stage 1.) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Fixes #107511
#106908 removed StorageDead without the accompanying StorageLive. In loops, execution would see repeated StorageLive, without any StorageDead, which is UB.
So when removing storage statements, we have to remove both StorageLive and StorageDead.
I also added a MIR validation pass for StorageLive. It may be a bit overzealous.