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

Check that move arguments are disjoint in the mir verifier #103363

Open
bjorn3 opened this issue Oct 21, 2022 · 6 comments
Open

Check that move arguments are disjoint in the mir verifier #103363

bjorn3 opened this issue Oct 21, 2022 · 6 comments
Labels
-Zvalidate-mir Unstable option: MIR validation A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html F-unsized_fn_params `#![feature(unsized_fn_params)]` T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@bjorn3
Copy link
Member

bjorn3 commented Oct 21, 2022

See https://rust-lang.zulipchat.com/#narrow/stream/136281-t-lang.2Fwg-unsafe-code-guidelines/topic/stack.20slot.20reuse.20Q/near/305409193 and #103362.

Basically the check would disallow foo(move _1, move _1) (where _1 is of any type) and foo(move *_1, move *_1) (where _1 is a box).

@bjorn3 bjorn3 added A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html F-unsized_fn_params `#![feature(unsized_fn_params)]` -Zvalidate-mir Unstable option: MIR validation labels Oct 21, 2022
@RalfJung
Copy link
Member

It should also reject foo(move _1, move *_1), probably.

@tmiasko
Copy link
Contributor

tmiasko commented Oct 21, 2022

One additional case that probably should be rejected: f(move _1, _1).

@scottmcm
Copy link
Member

Is f(_1, move _1) allowed?

@bjorn3
Copy link
Member Author

bjorn3 commented Oct 21, 2022

It could be, but it did be more consistent to disallow it and require an explicit copy rather than an implicit one.

@tmiasko
Copy link
Contributor

tmiasko commented Dec 7, 2022

There is an interesting report of a destination propagation introducing an overlap between moved argument and call destination in dead code #105344 (comment).

@bjorn3
Copy link
Member Author

bjorn3 commented Dec 7, 2022

I think destination propagation should be fixed in that case.

@Noratrieb Noratrieb added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Apr 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
-Zvalidate-mir Unstable option: MIR validation A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html F-unsized_fn_params `#![feature(unsized_fn_params)]` T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

5 participants