diff options
| author | Dylan DPC <99973273+Dylan-DPC@users.noreply.github.com> | 2022-04-02 03:34:24 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-04-02 03:34:24 +0200 |
| commit | d6f6084b24923f14bff0cf31ef78da9383cfb397 (patch) | |
| tree | c14660294ec1c2b522bf5aae2bd67a8ed9ca69ed /compiler/rustc_interface/src | |
| parent | 556c7411cc01c88d4656b65a28646fd945ac2a22 (diff) | |
| parent | 2a827635ba65e3d40af8643373e4584858eecc7d (diff) | |
| download | rust-d6f6084b24923f14bff0cf31ef78da9383cfb397.tar.gz rust-d6f6084b24923f14bff0cf31ef78da9383cfb397.zip | |
Rollup merge of #95556 - declanvk:nonnull-provenance, r=dtolnay
Implement provenance preserving methods on NonNull ### Description Add the `addr`, `with_addr`, `map_addr` methods to the `NonNull` type, and map the address type to `NonZeroUsize`. ### Motivation The `NonNull` type is useful for implementing pointer types which have the 0-niche. It is currently possible to implement these provenance preserving functions by calling `NonNull::as_ptr` and `new_unchecked`. The adding these methods makes it more ergonomic. ### Testing Added a unit test of a non-null tagged pointer type. This is based on some real code I have elsewhere, that currently routes the pointer through a `NonZeroUsize` and back out to produce a usable pointer. I wanted to produce an ideal version of the same tagged pointer struct that preserved pointer provenance. ### Related Extension of APIs proposed in #95228 . I can also split this out into a separate tracking issue if that is better (though I may need some pointers on how to do that).
Diffstat (limited to 'compiler/rustc_interface/src')
0 files changed, 0 insertions, 0 deletions
