-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Implement ptr::try_cast_aligned
and NonNull::try_cast_aligned
.
#141222
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This comment has been minimized.
This comment has been minimized.
|
r? libs-api |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two small requests and please squash, then lgtm
This comment has been minimized.
This comment has been minimized.
8cb6727
to
bb6afec
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes lgtm but would you mind cleaning up the commit message? It's a bit nonsensical (assuming this came from an autosquash)
Implement `ptr::try_cast_aligned`
`ptr::try_cast_aligned`: link tracking issue
`ptr::try_cast_aligned`: remove forgotten `const`
`NonNull::try_cast_aligned`: fix doctest
`ptr::try_cast_aligned`: #[inline]
ptr::`try_cast_aligned`: fix doc
Implement `ptr::try_cast_aligned` and `NonNull::try_cast_aligned`.
You should just be able to run git commit --amend
and delete everything but the first (or last) line, then git push --force-with-lease
.
bb6afec
to
9d1cf12
Compare
Did it work this time ? 😅 |
Great, thank you! @bors r+ rollup |
…iaskrgr Rollup of 6 pull requests Successful merges: - rust-lang#140981 (Add match guard let chain drop order and scoping tests) - rust-lang#141042 (ci: split powerpc64le-linux job) - rust-lang#141078 (ci: split dist-arm-linux job) - rust-lang#141222 (Implement `ptr::try_cast_aligned` and `NonNull::try_cast_aligned`.) - rust-lang#141308 (Do not call name() on rpitit assoc_item) - rust-lang#141316 (Update books) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#141222 - mathisbot:ptr_trycastaligned, r=tgross35 Implement `ptr::try_cast_aligned` and `NonNull::try_cast_aligned`. Implement three common methods on raw pointers and `NonNull`s: `try_cast_aligned`. ## Related links - Tracking Issue: rust-lang#141221 ## About `#[inline]` Since the result of a call to `align_of` is a power of two known at compile time, the compiler is able to reduce a call to `try_cast_aligned` to only test and sete (or test and jne if followed by `unwrap`), at least on every tier 1 target's arch. This seemed like a good reason to `#[inline]` the function. - https://godbolt.org/z/ocehvPWMx (raw inlining) - https://godbolt.org/z/3qa4j4Yrn (comparison with no inlining)
…rovenance, r=tgross35 try_cast_aligned: avoid bare int-to-ptr casts This fixes a CI failure in https://github.com/rust-lang/miri-test-libstd caused by strict provenance violations in doctests added in rust-lang#141222. r? `@tgross35` Cc `@mathisbot`
Rollup merge of rust-lang#141381 - RalfJung:try_cast_aligned-strict-provenance, r=tgross35 try_cast_aligned: avoid bare int-to-ptr casts This fixes a CI failure in https://github.com/rust-lang/miri-test-libstd caused by strict provenance violations in doctests added in rust-lang#141222. r? `@tgross35` Cc `@mathisbot`
Implement three common methods on raw pointers and
NonNull
s:try_cast_aligned
.Related links
#![feature(pointer_try_cast_aligned)]
#141221About
#[inline]
Since the result of a call to
align_of
is a power of two known at compile time, the compiler is able to reduce a call totry_cast_aligned
to only test and sete (or test and jne if followed byunwrap
), at least on every tier 1 target's arch. This seemed like a good reason to#[inline]
the function.