Uh oh!
There was an error while loading. Please reload this page.
Avoid Operand::Copy with &mut T - #72093
Conversation
rust-highfive
commented
May 10, 2020
(rust_highfive has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
petrochenkov
commented
May 11, 2020
r? @RalfJung |
RalfJung
commented
May 11, 2020
This code is entirely unfamiliar to me, sorry... no idea why @petrochenkov thought I might be a good reviewer here. |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Please add a mir-opt test showing this
oli-obk
commented
May 11, 2020
I think if we're enforcing this invariant, we should have a mir pass that validates the various (I guess we have more) invariants that we want to be upheld. We could have a flag that runs this That said, I am not sure what actual effects cc @rust-lang/wg-mir-opt |
There are ideas about making a EDIT: Here is the issue: rust-lang/unsafe-code-guidelines#188. |
jonas-schievink
commented
May 11, 2020
Having |
@jonas-schievink please post details in the issue I linked. So far, any time someone claimed that, a closer look revealed deinit-on- |
jonas-schievink
commented
May 11, 2020
Ah, yes, that one is what I meant |
#61849 is very different from rust-lang/unsafe-code-guidelines#188. #61849 is basically Deinit-on- |
bors
commented
May 21, 2020
☔ The latest upstream changes (presumably #72205) made this pull request unmergeable. Please resolve the merge conflicts. |
jonas-schievink
commented
May 23, 2020
I've added a small validation pass and a |
RalfJung
commented
May 23, 2020
That's awesome, I about about 100 ideas for things this could check.^^ Just talked about that with @eddyb earlier today, in fact. Can we run that pass at least once, say at the beginning and end of |
jonas-schievink
commented
May 23, 2020
I ran it on the testsuite already and found nothing. Right now it only checks 2 invariants though ( |
RalfJung
commented
May 23, 2020
No that was PMs on Zulip. The main other check is: for every assignment, make sure the type of LHS and RHS match. (They are not always fully equal though, just "compatible enough"). We could also check that there is only one |
RalfJung
commented
May 24, 2020
Good to know that this is true right now, but I'd prefer to make sure it stays that way. :) A check after every pass is probably overkill for that, but some check should IMO be done by default when debug assertions are enabled. |
I agree with running this check once when debug assertions are enabled. Maybe at the end of r=me with that |
jonas-schievink
commented
May 25, 2020
@bors r=oli-obk rollup=never |
bors
commented
May 25, 2020
📌 Commit fe1753a has been approved by |
bors
commented
May 26, 2020
bors
commented
May 26, 2020
☀️ Test successful - checks-azure |
| body.phase = mir_phase; | ||
| if mir_phase == MirPhase::Optimized { | ||
| validate::Validator { when: format!("end of phase {:?}", mir_phase) } |
There was a problem hiding this comment.
So we run it here even without debug assertions? Isn't that expensive?
There was a problem hiding this comment.
The pass does very little work, so it's unlikely to be an issue
There was a problem hiding this comment.
The pass does very little work
That is something I want to change.^^ #72796 does some non-trivial type folding.
…ewjasper MIR sanity check: validate types on assignment This expands the MIR validation added by @jonas-schievink in rust-lang#72093 to also check that on an assignment, the types of both sides match. Cc @eddyb@oli-obk
…ewjasper MIR sanity check: validate types on assignment This expands the MIR validation added by @jonas-schievink in rust-lang#72093 to also check that on an assignment, the types of both sides match. Cc @eddyb@oli-obk
…ewjasper MIR sanity check: validate types on assignment This expands the MIR validation added by @jonas-schievink in rust-lang#72093 to also check that on an assignment, the types of both sides match. Cc @eddyb@oli-obk
This is generally unsound to do, as the copied type is assumed to implement
Copy.Closes#46420