rust/compiler/rustc_codegen_llvm/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 Replace Session should_remap_filepaths with filename_display_preference 2024-03-28 18:47:26 +01:00
coverageinfo Auto merge of #122972 - beetrees:use-align-type, r=fee1-dead 2024-04-01 03:16:45 +00:00
debuginfo Replace Session should_remap_filepaths with filename_display_preference 2024-03-28 18:47:26 +01:00
llvm Use the Align type when parsing alignment attributes 2024-04-01 03:05:55 +01:00
abi.rs make PassMode::Cast consistently copy between Rust/ABI representation 2024-03-17 00:39:21 -04:00
allocator.rs Add -Zuse-sync-unwind 2023-12-31 15:27:43 +08:00
asm.rs CFI: Use Instance at callsites 2024-03-23 18:30:39 +00:00
attributes.rs Use the Align type when parsing alignment attributes 2024-04-01 03:05:55 +01:00
base.rs compiler: replace cstr macro with c str literals in compiler and few other c str replacements 2023-12-03 14:54:09 +03:00
builder.rs Auto merge of #122849 - clubby789:no-metadata, r=petrochenkov 2024-03-26 06:46:43 +00:00
callee.rs Fix clippy::needless_borrow in the compiler 2023-11-21 20:13:40 +01:00
common.rs Add+Use mir::BinOp::Cmp 2024-03-23 23:23:41 -07:00
consts.rs Some comment nits 2024-03-12 08:51:20 +00:00
context.rs Auto merge of #119552 - krtab:dead_code_priv_mod_pub_field, r=cjgillot,saethlin 2024-03-23 00:37:05 +00:00
declare.rs CFI: Fix methods as function pointer cast 2024-03-27 16:19:17 -07:00
errors.rs Rename IntoDiagnostic as Diagnostic. 2024-03-11 09:15:09 +11:00
intrinsic.rs rename expose_addr to expose_provenance 2024-04-03 16:00:38 +02:00
lib.rs compiler: use addr_of! 2024-02-24 18:53:48 +03:00
llvm_util.rs Register LLVM handlers for bad-alloc / OOM 2024-03-15 15:49:06 -07:00
mono_item.rs Some comment nits 2024-03-12 08:51:20 +00:00
type_.rs Fix 32-bit overflows in LLVM composite constants 2024-03-10 17:54:55 -04:00
type_of.rs Remove the unused field_remapping field from TypeLowering 2024-03-08 03:42:47 +00:00
va_arg.rs Add arm64ec-pc-windows-msvc target 2024-03-06 17:49:37 -08:00
value.rs