diff options
| author | bors <bors@rust-lang.org> | 2022-05-18 23:18:03 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-05-18 23:18:03 +0000 |
| commit | d8a3fc4d71bae720cc2534ff5b97164f47622e12 (patch) | |
| tree | 683bdc9c71844589da8f028471e762eb03d77dd3 /compiler/rustc_codegen_llvm/src | |
| parent | cd282d7f75da9080fda0f1740a729516e7fbec68 (diff) | |
| parent | 03d45699390421d6a27f5ae2dc10077b38d950fe (diff) | |
| download | rust-d8a3fc4d71bae720cc2534ff5b97164f47622e12.tar.gz rust-d8a3fc4d71bae720cc2534ff5b97164f47622e12.zip | |
Auto merge of #95643 - WaffleLapkin:ptr_convenience, r=joshtriplett
Add convenience byte offset/check align functions to pointers
This PR adds the following APIs:
```rust
impl *const T {
// feature gates `pointer_byte_offsets` and `const_pointer_byte_offsets
pub const unsafe fn byte_offset(self, count: isize) -> Self;
pub const fn wrapping_byte_offset(self, count: isize) -> Self;
pub const unsafe fn byte_offset_from(self, origin: *const T) -> isize;
pub const unsafe fn byte_add(self, count: usize) -> Self;
pub const unsafe fn byte_sub(self, count: usize) -> Self;
pub const fn wrapping_byte_add(self, count: usize) -> Self;
pub const fn wrapping_byte_sub(self, count: usize) -> Self;
// feature gate `pointer_is_aligned`
pub fn is_aligned(self) -> bool where T: Sized;
pub fn is_aligned_to(self, align: usize) -> bool;
}
// ... and the same for` *mut T`
```
Note that all functions except `is_aligned` do **not** require `T: Sized` as their pointee-sized-offset counterparts.
cc `@oli-obk` (you may want to check that I've correctly placed `const`s)
cc `@RalfJung`
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
0 files changed, 0 insertions, 0 deletions
