rust/compiler/rustc_codegen_ssa/src
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
..
back and few more 2024-03-28 16:26:37 +03:00
debuginfo Programmatically convert some of the pat ctors 2024-03-22 11:13:29 -04:00
mir Rollup merge of #122964 - joboet:pointer_expose, r=Amanieu 2024-04-03 22:11:00 +02:00
traits Auto merge of #118310 - scottmcm:three-way-compare, r=davidtwco 2024-04-02 19:21:44 +00:00
assert_module_sources.rs Rename IntoDiagnosticArg as IntoDiagArg. 2024-03-11 09:12:19 +11:00
base.rs Improve the build_shift_expr_rhs comment 2024-04-02 10:17:21 -07:00
codegen_attrs.rs Fix misleading message when using a named constant as a struct alignment/pack 2024-03-02 23:15:39 +08:00
common.rs De-LLVM the unchecked shifts [MCP#693] 2024-03-30 03:32:11 -07:00
errors.rs Handle calls to upstream monomorphizations in compiler_builtins 2024-03-16 15:22:05 -04:00
lib.rs Stabilize associated type bounds 2024-03-08 20:56:25 +00:00
meth.rs use ptradd for vtable indexing 2024-03-10 22:47:30 -04:00
mono_item.rs Fix ICE: global_asm!() Don't Panic When Unable to Evaluate Constant 2024-03-18 11:35:40 -04:00
size_of_val.rs CFI: Use Instance at callsites 2024-03-23 18:30:39 +00:00
target_features.rs Bump indexmap 2024-02-13 21:03:34 +00:00