-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Looser check for overflowing_binary_op #91856
Conversation
Some changes occured to the CTFE / Miri engine cc @rust-lang/miri |
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @cjgillot (or someone else) soon. Please see the contribution instructions for more information. |
This comment has been minimized.
This comment has been minimized.
Higher kinded lifetimes strike again... I think the real fix would be to use the subtyping infra, but that could be rather expensive for such a common op. Although it short circuits on type equality, so it should be cheap most of the time |
I tried other things to fix this but they broke a lot of stuff 😸 I will look at subtyping infra, thanks! |
I think something like |
Or maybe check how mir validation does it, tho I fear it just bails out on such lifetimes |
I think because of |
OK, I guess if the subtyping check works here, we should make mir validation use it, too? |
Again for such a small case wouldn't adding an extra layer of subtyping check make it slow ? 😕 |
Also |
I think MIR validation currently doesn't check much about operators (unary and binary alike), so that sounds like a separate PR to me. |
@@ -330,7 +330,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { | |||
_ if left.layout.ty.is_any_ptr() => { | |||
// The RHS type must be the same *or an integer type* (for `Offset`). |
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.
Please update this comment, adding a link to #91636.
Yeah I am fine with this change. I proposed it. :) @ouz-a could you add #91636 (comment) add a regression test? Other than that and the comment nit I raised, this looks good to me! |
Going to update the comment and add a regression test. Thanks! |
This comment has been minimized.
This comment has been minimized.
@bors r+ |
📌 Commit b85762f has been approved by |
@bors rollup |
@@ -328,9 +328,10 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { | |||
self.binary_int_op(bin_op, l, left.layout, r, right.layout) | |||
} | |||
_ if left.layout.ty.is_any_ptr() => { | |||
// The RHS type must be the same *or an integer type* (for `Offset`). | |||
// The RHS type must be a `pointer` *or an integer type* (for `Offset`). | |||
// (This is workaround for the issue #91636) |
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.
// (This is workaround for the issue #91636) | |
// (Even when both sides are pointers, their type might differ, see issue #91636) |
Comment nit |
@bors r+ rollup |
📌 Commit a5054e3 has been approved by |
…askrgr Rollup of 7 pull requests Successful merges: - rust-lang#89825 (Make split_inclusive() on an empty slice yield an empty output) - rust-lang#91239 (regression test for issue 87490) - rust-lang#91597 (Recover on invalid operators `<>` and `<=>`) - rust-lang#91774 (Fix typo for MutVisitor) - rust-lang#91786 (Return an error when `eval_rvalue_with_identities` fails) - rust-lang#91798 (Avoid suggest adding `self` in visibility spec) - rust-lang#91856 (Looser check for overflowing_binary_op) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
add regression test Adds a regression test for rust-lang/rust#91636 (which was fixed by rust-lang/rust#91856)
add regression test Adds a regression test for rust-lang/rust#91636 (which was fixed by rust-lang/rust#91856)
add regression test Adds a regression test for rust-lang/rust#91636 (which was fixed by rust-lang/rust#91856)
Fix for issue #91636 tight check resulted in ICE, this makes the check a little looser. It seems
eq
allows comparing ofsupertype
andsubtype
iflhs = supertype
andrhs = subtype
but not vice versa, is this intended behavior ?