about summary refs log tree commit diff
path: root/compiler/rustc_interface/src/errors.rs
diff options
context:
space:
mode:
authorAndreas Molzer <andreas.molzer@nebumind.com>2022-10-21 14:05:45 +0200
committerAndreas Molzer <andreas.molzer@nebumind.com>2022-10-21 14:46:14 +0200
commit71c39dea4d18373e4da35838332071562ea44d33 (patch)
treee378e604bd197d7400cbaa52ed616769e964a6d7 /compiler/rustc_interface/src/errors.rs
parentb1ab3b738ac718da74cd4aa0bb7f362d0adbdf84 (diff)
downloadrust-71c39dea4d18373e4da35838332071562ea44d33.tar.gz
rust-71c39dea4d18373e4da35838332071562ea44d33.zip
Argument type for mutable with_metadata_of (#75091)
The method takes two pointer arguments: one `self` supplying the pointer
value, and a second pointer supplying the metadata.

The new parameter type more clearly reflects the actual requirements.
The provenance of the metadata parameter is disregarded completely.
Using a mutable pointer in the call site can be coerced to a const
pointer while the reverse is not true.

An example of the current use:

```rust
// Manually taking an unsized object from a `ManuallyDrop` into another allocation.
let val: &core::mem::ManuallyDrop<T> = …;

let ptr = val as *const _ as *mut T;
let ptr = uninit.as_ptr().with_metadata_of(ptr);
```

This could then instead be simplified to:

```rust
// Manually taking an unsized object from a `ManuallyDrop` into another allocation.
let val: &core::mem::ManuallyDrop<T> = …;

let ptr = uninit.as_ptr().with_metadata_of(&**val);
```
Diffstat (limited to 'compiler/rustc_interface/src/errors.rs')
0 files changed, 0 insertions, 0 deletions