Find a file
Matthias Krüger 80d592cc24
Rollup merge of #122964 - joboet:pointer_expose, r=Amanieu
Rename `expose_addr` to `expose_provenance`

`expose_addr` is a bad name, an address is just a number and cannot be exposed. The operation is actually about the provenance of the pointer.

This PR thus changes the name of the method to `expose_provenance` without changing its return type. There is sufficient precedence for returning a useful value from an operation that does something else without the name indicating such, e.g. [`Option::insert`](https://doc.rust-lang.org/nightly/std/option/enum.Option.html#method.insert) and [`MaybeUninit::write`](https://doc.rust-lang.org/nightly/std/mem/union.MaybeUninit.html#method.write).

Returning the address is merely convenient, not a fundamental part of the operation. This is implied by the fact that integers do not have provenance since
```rust
let addr = ptr.addr();
ptr.expose_provenance();
let new = ptr::with_exposed_provenance(addr);
```
must behave exactly like
```rust
let addr = ptr.expose_provenance();
let new = ptr::with_exposed_provenance(addr);
```
as the result of `ptr.expose_provenance()` and `ptr.addr()` is the same integer. Therefore, this PR removes the `#[must_use]` annotation on the function and updates the documentation to reflect the important part.

~~An alternative name would be `expose_provenance`. I'm not at all opposed to that, but it makes a stronger implication than we might want that the provenance of the pointer returned by `ptr::with_exposed_provenance`[^1] is the same as that what was exposed, which is not yet specified as such IIUC. IMHO `expose` does not make that connection.~~

A previous version of this PR suggested `expose` as name, libs-api [decided on](https://github.com/rust-lang/rust/pull/122964#issuecomment-2033194319) `expose_provenance` to keep the symmetry with `with_exposed_provenance`.

CC `@RalfJung`
r? libs-api

[^1]: I'm using the new name for `from_exposed_addr` suggested by #122935 here.
2024-04-03 22:11:00 +02:00
.github Revert cargo update changes 2024-03-26 15:36:12 +00:00
.reuse std: move Once implementations to sys 2024-03-12 15:41:06 +01:00
compiler Rollup merge of #122964 - joboet:pointer_expose, r=Amanieu 2024-04-03 22:11:00 +02:00
library Rollup merge of #122964 - joboet:pointer_expose, r=Amanieu 2024-04-03 22:11:00 +02:00
LICENSES
src Rollup merge of #122964 - joboet:pointer_expose, r=Amanieu 2024-04-03 22:11:00 +02:00
tests Rollup merge of #122964 - joboet:pointer_expose, r=Amanieu 2024-04-03 22:11:00 +02:00
.editorconfig
.git-blame-ignore-revs Ignore compiletest test directive migration commits 2024-02-22 18:55:02 +00:00
.gitattributes
.gitignore
.gitmodules
.mailmap Add my former address to .mailmap 2024-03-25 18:48:54 -07:00
Cargo.lock Rollup merge of #123378 - ferrocene:hoverbear/bump-sysinfo-to-0.30.8, r=Nilstrieb 2024-04-02 21:22:04 +02:00
Cargo.toml Update to Cranelift 0.106 2024-03-22 18:34:00 +00:00
CODE_OF_CONDUCT.md
config.example.toml use more accurate terminology 2024-03-19 20:32:55 +02:00
configure
CONTRIBUTING.md
COPYRIGHT
INSTALL.md chore: fix some comments 2024-03-27 22:32:53 +08:00
LICENSE-APACHE
LICENSE-MIT
README.md
RELEASES.md Forward port 1.77.1 release notes 2024-03-29 10:44:19 +03:00
rust-bors.toml Increase timeout for new bors bot 2024-03-13 08:31:07 +01:00
rustfmt.toml Remove exception for deleted file from rustfmt.toml 2024-03-08 20:46:33 +00:00
triagebot.toml beep boop 2024-03-31 20:18:37 +01:00
x
x.ps1
x.py

The Rust Programming Language

Rust Community

This is the main source code repository for Rust. It contains the compiler, standard library, and documentation.

Note: this README is for users rather than contributors. If you wish to contribute to the compiler, you should read CONTRIBUTING.md instead.

Table of Contents

Quick Start

Read "Installation" from The Book.

Installing from Source

If you really want to install from source (though this is not recommended), see INSTALL.md.

Getting Help

See https://www.rust-lang.org/community for a list of chat platforms and forums.

Contributing

See CONTRIBUTING.md.

License

Rust is primarily distributed under the terms of both the MIT license and the Apache License (Version 2.0), with portions covered by various BSD-like licenses.

See LICENSE-APACHE, LICENSE-MIT, and COPYRIGHT for details.

Trademark

The Rust Foundation owns and protects the Rust and Cargo trademarks and logos (the "Rust Trademarks").

If you want to use these names or brands, please read the media guide.

Third-party logos may be subject to third-party copyrights and trademarks. See Licenses for details.