-
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
interpret: unify offset_from check with offset check #97960
Conversation
Some changes occured to the CTFE / Miri engine cc @rust-lang/miri |
@@ -243,7 +243,7 @@ error[E0080]: could not evaluate static initializer | |||
LL | unsafe { intrinsics::ptr_offset_from_unsigned(self, origin) } | |||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | |||
| | | |||
| ptr_offset_from_unsigned cannot compute offset of pointers into different allocations. | |||
| ptr_offset_from_unsigned called on pointers into different allocations |
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.
Interestingly the error does not even say that this is UB. It just says "could not evaluate static initializer". Maybe as part of rust-lang/miri#2200 we should also improve the const-eval errors.
@bors r+ rollup |
📌 Commit e5245ef has been approved by |
interpret: unify offset_from check with offset check `offset` does the check with a single `check_ptr_access` call while `offset_from` used two calls. Make them both just one one call. I originally intended to actually factor this into a common function, but I am no longer sure if that makes a lot of sense... the two functions start with pretty different precondition (e.g. `offset` *knows* that the 2nd pointer has the same provenance). I also reworded the UB messages a little. Saying it "cannot" do something is not how we usually phrase UB (as far as I know). Instead it's not *allowed* to do that. r? `@oli-obk`
interpret: unify offset_from check with offset check `offset` does the check with a single `check_ptr_access` call while `offset_from` used two calls. Make them both just one one call. I originally intended to actually factor this into a common function, but I am no longer sure if that makes a lot of sense... the two functions start with pretty different precondition (e.g. `offset` *knows* that the 2nd pointer has the same provenance). I also reworded the UB messages a little. Saying it "cannot" do something is not how we usually phrase UB (as far as I know). Instead it's not *allowed* to do that. r? ``@oli-obk``
interpret: unify offset_from check with offset check `offset` does the check with a single `check_ptr_access` call while `offset_from` used two calls. Make them both just one one call. I originally intended to actually factor this into a common function, but I am no longer sure if that makes a lot of sense... the two functions start with pretty different precondition (e.g. `offset` *knows* that the 2nd pointer has the same provenance). I also reworded the UB messages a little. Saying it "cannot" do something is not how we usually phrase UB (as far as I know). Instead it's not *allowed* to do that. r? ```@oli-obk```
interpret: unify offset_from check with offset check `offset` does the check with a single `check_ptr_access` call while `offset_from` used two calls. Make them both just one one call. I originally intended to actually factor this into a common function, but I am no longer sure if that makes a lot of sense... the two functions start with pretty different precondition (e.g. `offset` *knows* that the 2nd pointer has the same provenance). I also reworded the UB messages a little. Saying it "cannot" do something is not how we usually phrase UB (as far as I know). Instead it's not *allowed* to do that. r? ````@oli-obk````
interpret: unify offset_from check with offset check `offset` does the check with a single `check_ptr_access` call while `offset_from` used two calls. Make them both just one one call. I originally intended to actually factor this into a common function, but I am no longer sure if that makes a lot of sense... the two functions start with pretty different precondition (e.g. `offset` *knows* that the 2nd pointer has the same provenance). I also reworded the UB messages a little. Saying it "cannot" do something is not how we usually phrase UB (as far as I know). Instead it's not *allowed* to do that. r? `````@oli-obk`````
…askrgr Rollup of 10 pull requests Successful merges: - rust-lang#97709 (Normalize consts' tys when relating with `adt_const_params`) - rust-lang#97875 (Remove the `infer_static_outlives_requirements` feature) - rust-lang#97960 (interpret: unify offset_from check with offset check) - rust-lang#97999 (Make `type_changing_struct_update` no longer an incomplete feature) - rust-lang#98043 (Remove unnecessary `to_string` and `String::new`) - rust-lang#98044 ([issues:97981] del unrelated comment) - rust-lang#98049 (Document an edge case of `str::split_once`) - rust-lang#98050 (Add some more regression tests for rust-lang#67945) - rust-lang#98054 (Fix error message for `download-ci-llvm`) - rust-lang#98057 (Update miri) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
offset
does the check with a singlecheck_ptr_access
call whileoffset_from
used two calls. Make them both just one one call.I originally intended to actually factor this into a common function, but I am no longer sure if that makes a lot of sense... the two functions start with pretty different precondition (e.g.
offset
knows that the 2nd pointer has the same provenance).I also reworded the UB messages a little. Saying it "cannot" do something is not how we usually phrase UB (as far as I know). Instead it's not allowed to do that.
r? @oli-obk