-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Miri: dispatch first on the type #62946
Conversation
r? @estebank (rust_highfive has picked a reviewer for you, use r? to override) |
The Miri side of this is at rust-lang/miri#856. I verified that the test suite passes. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
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.
Just some nits
Actually, the PR as-is makes this fail: const X2: bool = unsafe { 42 as *const i32 == 43 as *const i32 }; The reason is that I suppose this is something we have to keep working, for backwards compatibility? |
If we do want this, I think the cleanest way would be to move https://github.com/rust-lang/miri/blob/5a9ea5d1b61a860b95916366b17cce8349450332/src/operator.rs#L52-L78 into the engine. It will still fail in CTFE if either input is a pointer because What do you think? |
No, just break it. Pointer comparisons are unstable at the type level for a reason |
@oli-obk I think I took care of your nits. I also had to update some test files and rebase. Please check. |
54f900f
to
3cd4079
Compare
This comment has been minimized.
This comment has been minimized.
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.
nits
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Now that's surprising, why does this affect |
Turns out const_prop was doing ptr-to-int casts based on CTFE doing that. With CTFE not doing that any more, const_prop cannot do it any more, either. Cc @wesleywiser |
@bors r+ |
📌 Commit d7b9bbf has been approved by |
…en dispatching further; call ptr_op machine hook only for pointer types
Co-Authored-By: Mazdak Farrokhzad <[email protected]>
12a29d9
to
b9db95e
Compare
Rebased. @bors r=oli-obk |
📌 Commit b9db95e has been approved by |
Miri: dispatch first on the type Based on the fact that Miri now always has intptrcast available, we can change binops and casts to first check the type of the source operand and then decide based on that what to do, instead of considering the value (pointer vs bits) first.
☀️ Test successful - checks-azure |
Adjust for ptr_op changes This is the Miri side of rust-lang/rust#62946.
Adjust for ptr_op changes This is the Miri side of rust-lang/rust#62946.
Based on the fact that Miri now always has intptrcast available, we can change binops and casts to first check the type of the source operand and then decide based on that what to do, instead of considering the value (pointer vs bits) first.