rust/src/tools
Matthias Krüger 20b1dadf92
Rollup merge of #130350 - RalfJung:strict-provenance, r=dtolnay
stabilize Strict Provenance and Exposed Provenance APIs

Given that [RFC 3559](https://rust-lang.github.io/rfcs/3559-rust-has-provenance.html) has been accepted, t-lang has approved the concept of provenance to exist in the language. So I think it's time that we stabilize the strict provenance and exposed provenance APIs, and discuss provenance explicitly in the docs:
```rust
// core::ptr
pub const fn without_provenance<T>(addr: usize) -> *const T;
pub const fn dangling<T>() -> *const T;
pub const fn without_provenance_mut<T>(addr: usize) -> *mut T;
pub const fn dangling_mut<T>() -> *mut T;
pub fn with_exposed_provenance<T>(addr: usize) -> *const T;
pub fn with_exposed_provenance_mut<T>(addr: usize) -> *mut T;

impl<T: ?Sized> *const T {
    pub fn addr(self) -> usize;
    pub fn expose_provenance(self) -> usize;
    pub fn with_addr(self, addr: usize) -> Self;
    pub fn map_addr(self, f: impl FnOnce(usize) -> usize) -> Self;
}

impl<T: ?Sized> *mut T {
    pub fn addr(self) -> usize;
    pub fn expose_provenance(self) -> usize;
    pub fn with_addr(self, addr: usize) -> Self;
    pub fn map_addr(self, f: impl FnOnce(usize) -> usize) -> Self;
}

impl<T: ?Sized> NonNull<T> {
    pub fn addr(self) -> NonZero<usize>;
    pub fn with_addr(self, addr: NonZero<usize>) -> Self;
    pub fn map_addr(self, f: impl FnOnce(NonZero<usize>) -> NonZero<usize>) -> Self;
}
```

I also did a pass over the docs to adjust them, because this is no longer an "experiment". The `ptr` docs now discuss the concept of provenance in general, and then they go into the two families of APIs for dealing with provenance: Strict Provenance and Exposed Provenance. I removed the discussion of how pointers also have an associated "address space" -- that is not actually tracked in the pointer value, it is tracked in the type, so IMO it just distracts from the core point of provenance. I also adjusted the docs for `with_exposed_provenance` to make it clear that we cannot guarantee much about this function, it's all best-effort.

There are two unstable lints associated with the strict_provenance feature gate; I moved them to a new [strict_provenance_lints](https://github.com/rust-lang/rust/issues/130351) feature since I didn't want this PR to have an even bigger FCP. ;)

`@rust-lang/opsem` Would be great to get some feedback on the docs here. :)
Nominating for `@rust-lang/libs-api.`

Part of https://github.com/rust-lang/rust/issues/95228.

[FCP comment](https://github.com/rust-lang/rust/pull/130350#issuecomment-2395114536)
2024-10-21 18:11:19 +02:00
..
build-manifest Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
build_helper Rollup merge of #131358 - onur-ozkan:129528, r=Mark-Simulacrum 2024-10-12 21:38:36 -05:00
bump-stage0 Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
cargo@cf53cc54bb Update cargo 2024-10-18 18:00:28 -04:00
cargotest Reformat use declarations. 2024-07-29 08:26:52 +10:00
clippy Auto merge of #131988 - matthiaskrgr:rollup-tx173wn, r=matthiaskrgr 2024-10-21 06:13:34 +00:00
collect-license-metadata Update generate-copyright 2024-08-06 11:04:55 +01:00
compiletest compiletest: disambiguate between tidy and tidy (html version) 2024-10-20 14:30:52 +08:00
coverage-dump coverage: Include the highest counter ID seen in .cov-map dumps 2024-10-11 21:04:37 +11:00
enzyme@2fe5164a24 Enzyme backend 2024-09-05 22:47:23 -04:00
error_index_generator Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
generate-copyright Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
generate-windows-sys Add windows-targets crate to std's sysroot 2024-08-09 10:43:43 +00:00
html-checker rustdoc: redesign toolbar and disclosure widgets 2024-09-10 17:56:05 -07:00
jsondocck Reformat use declarations. 2024-07-29 08:26:52 +10:00
jsondoclint Update rustc-hash to version 2 2024-10-20 00:12:49 -07:00
libcxx-version skip src/tools/libcxx-version from tidy 2024-06-06 07:01:37 +03:00
linkchecker update the doc comment on lintchecker b/c it parses html now 2024-08-24 12:35:35 -04:00
lint-docs Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
lld-wrapper Reformat use declarations. 2024-07-29 08:26:52 +10:00
llvm-bitcode-linker Reformat use declarations. 2024-07-29 08:26:52 +10:00
miri Rollup merge of #130350 - RalfJung:strict-provenance, r=dtolnay 2024-10-21 18:11:19 +02:00
miropt-test-tools Emit error on skip-filecheck test containing filecheck directives 2024-10-19 13:24:07 +00:00
nix-dev-shell Add an option of using nix-shell instead of nix flake 2024-09-21 11:44:38 +02:00
opt-dist Remove valgrind test suite from opt-dist 2024-10-07 07:54:57 +00:00
remote-test-client Reformat use declarations. 2024-07-29 08:26:52 +10:00
remote-test-server Reformat use declarations. 2024-07-29 08:26:52 +10:00
replace-version-placeholder Reformat use declarations. 2024-07-29 08:26:52 +10:00
rls Reformat use declarations. 2024-07-29 08:26:52 +10:00
run-make-support Avoid cross-file glob import 2024-10-12 11:59:57 +11:00
rust-analyzer Rollup merge of #131942 - workingjubilee:reduce-haruspicy, r=lukas-code,lnicola 2024-10-20 14:06:04 +11:00
rust-installer Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
rustbook cargo update 2024-09-29 00:22:29 +00:00
rustc-perf@d5055e7804 bump up rustc-perf's version 2024-08-09 01:24:39 +09:00
rustc-perf-wrapper impl compare command and benchmark command to rustc-perf-wrapper 2024-08-09 20:03:14 +09:00
rustdoc Link std statically in rustc_driver 2024-08-11 04:16:53 +02:00
rustdoc-gui Enable --no-sandbox option by default for rustdoc GUI tests 2024-10-04 12:11:23 +02:00
rustdoc-gui-test Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustdoc-js Separate core search logic with search ui 2024-08-29 00:26:16 +08:00
rustdoc-themes Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
rustfmt Rewrite for<..> async correctly 2024-10-15 10:22:03 -04:00
suggest-tests Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
tidy Auto merge of #131949 - Noratrieb:fxhashup-thanks-alona, r=WaffleLapkin 2024-10-20 19:01:54 +00:00
tier-check Add NuttX based targets for RISC-V and ARM 2024-07-19 22:00:42 +08:00
unicode-table-generator Rollup merge of #131647 - jieyouxu:unicode-table-generator, r=Mark-Simulacrum 2024-10-20 16:54:09 +02:00
unstable-book-gen Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
wasm-component-ld Update wasm-component-ld to 0.5.10 2024-10-09 13:21:00 -07:00
x Reformat use declarations. 2024-07-29 08:26:52 +10:00
cherry-pick.sh
publish_toolstate.py Resolved python deprecation warning in publish_toolstate.py 2024-10-14 15:27:37 -04:00