rust/tests
bors 5d328a1f62 Auto merge of #117329 - RalfJung:offset-by-zero, r=oli-obk,scottmcm
offset: allow zero-byte offset on arbitrary pointers

As per prior `@rust-lang/opsem` [discussion](https://github.com/rust-lang/opsem-team/issues/10) and [FCP](https://github.com/rust-lang/unsafe-code-guidelines/issues/472#issuecomment-1793409130):

- Zero-sized reads and writes are allowed on all sufficiently aligned pointers, including the null pointer
- Inbounds-offset-by-zero is allowed on all pointers, including the null pointer
- `offset_from` on two pointers derived from the same allocation is always allowed when they have the same address

This removes surprising UB (in particular, even C++ allows "nullptr + 0", which we currently disallow), and it brings us one step closer to an important theoretical property for our semantics ("provenance monotonicity": if operations are valid on bytes without provenance, then adding provenance can't make them invalid).

The minimum LLVM we require (v17) includes https://reviews.llvm.org/D154051, so we can finally implement this.

The `offset_from` change is needed to maintain the equivalence with `offset`: if `let ptr2 = ptr1.offset(N)` is well-defined, then `ptr2.offset_from(ptr1)` should be well-defined and return N. Now consider the case where N is 0 and `ptr1` dangles: we want to still allow offset_from here.

I think we should change offset_from further, but that's a separate discussion.

Fixes https://github.com/rust-lang/rust/issues/65108
[Tracking issue](https://github.com/rust-lang/rust/issues/117945) | [T-lang summary](https://github.com/rust-lang/rust/pull/117329#issuecomment-1951981106)

Cc `@nikic`
2024-05-22 13:04:14 +00:00
..
assembly test: Add assembly tests for x86_64-unknown-linux-none target 2024-05-12 01:25:11 +02:00
auxiliary
codegen Auto merge of #125298 - tesuji:arrcmp, r=nikic 2024-05-21 05:55:39 +00:00
codegen-units Fix some minor issues from the ui-test auto-porting 2024-05-11 19:58:35 -04:00
coverage coverage: Simplify counter expressions using simple algebra 2024-05-14 13:58:40 +10:00
coverage-run-rustdoc
crashes Auto merge of #124227 - compiler-errors:hack-check-method-res, r=estebank 2024-05-22 10:57:59 +00:00
debuginfo Fix tests/debuginfo/strings-and-strs. 2024-05-20 15:01:59 +10:00
incremental Update tests/incremental/foreign.rs 2024-05-20 11:13:10 -04:00
mir-opt Rollup merge of #125173 - scottmcm:never-checked, r=davidtwco 2024-05-20 18:13:48 +02:00
pretty hir pretty: fix block indent 2024-05-20 20:30:44 +02:00
run-make Rollup merge of #125357 - GuillaumeGomez:migrate-rustdoc-scrape-examples-multiple, r=jieyouxu 2024-05-21 20:28:49 +02:00
run-make-fulldeps
run-pass-valgrind
rustdoc Add failing test for cross-crate enum in type alias 2024-05-19 20:13:18 -04:00
rustdoc-gui Rollup merge of #124738 - notriddle:notriddle/search-form-js, r=GuillaumeGomez 2024-05-07 18:12:54 +02:00
rustdoc-js
rustdoc-js-std
rustdoc-json
rustdoc-ui Always hide private fields in aliased type 2024-05-11 13:11:46 +02:00
ui Auto merge of #117329 - RalfJung:offset-by-zero, r=oli-obk,scottmcm 2024-05-22 13:04:14 +00:00
ui-fulldeps Add ErrorGuaranteed to Recovered::Yes and use it more. 2024-05-09 20:12:07 +10:00
COMPILER_TESTS.md