Uh oh!
There was an error while loading. Please reload this page.
adds [*mut|*const] ptr::set_ptr_value - #74774
Conversation
rust-highfive
commented
Jul 26, 2020
r? @dtolnay (rust_highfive has picked a reviewer for you, use r? to override) |
dtolnay
left a comment
There was a problem hiding this comment.
These should go further down in the documentation. Near the offsetting methods would make sense. Maybe in between wrapping_sub and read.
oliver-giersch
commented
Jul 26, 2020
Done. Although I always thought documentation was generated alphabetically, so in-file function order did not matter? |
bors
commented
Jul 28, 2020
☔ The latest upstream changes (presumably #73265) made this pull request unmergeable. Please resolve the merge conflicts. |
oliver-giersch
commented
Jul 31, 2020
made a complete mess trying to merge the recent directory structure changes, but everything should be ok again |
dtolnay
left a comment
There was a problem hiding this comment.
LGTM. Could you open a tracking issue and update the issue number in the unstable attributes in the PR?
dtolnay
commented
Aug 3, 2020
@bors r+ |
bors
commented
Aug 3, 2020
📌 Commit 6c81556 has been approved by |
bors
commented
Aug 3, 2020
⌛ Testing commit 6c81556 with merge 24265c7b79dcb81fb22b9d4c8e14acb89cb7a736... |
bors
commented
Aug 3, 2020
💥 Test timed out |
oliver-giersch
commented
Aug 4, 2020
What's the significance of the test time out and what can I do about it? |
ecstatic-morse
commented
Aug 6, 2020
@bors retry |
RalfJung
commented
Aug 6, 2020
I think there is some code in |
Uh oh!
There was an error while loading. Please reload this page.
CAD97
commented
Aug 7, 2020
Mild concern: this is The version of this in the |
CAD97
commented
Aug 7, 2020
Mild concern: a main usecase of this is to implement the [ Offsetting a pointer to sized type by a byte offset is At the least, I think it'd be better for the "pointer to data" pointer for these methods to be |
adds [*mut|*const] ptr::set_ptr_value I propose the addition of these two functions to `*mut T` and `*const T`, respectively. The motivation for this is primarily byte-wise pointer arithmetic on (potentially) fat pointers, i.e. for types with a `T: ?Sized` bound. A concrete use-case has been discussed in [this](https://internals.rust-lang.org/t/byte-wise-fat-pointer-arithmetic/12739) thread. TL;DR: Currently, byte-wise pointer arithmetic with potentially fat pointers in not possible in either stable or nightly Rust without making assumptions about the layout of fat pointers, which is currently still an implementation detail and not formally stabilized. This PR adds one function to `*mut T` and `*const T` each, allowing to circumvent this restriction without exposing any internal implementation details. One possible alternative would be to add specific byte-wise pointer arithmetic functions to the two pointer types in addition to the already existing count-wise functions. However, I feel this fairly niche use case does not warrant adding a whole set of new functions like `add_bytes`, `offset_bytes`, `wrapping_offset_bytes`, etc. (times two, one for each pointer type) to `libcore`.
oliver-giersch
commented
Aug 7, 2020
…arth Rollup of 4 pull requests Successful merges: - rust-lang#74774 (adds [*mut|*const] ptr::set_ptr_value) - rust-lang#75079 (Disallow linking to items with a mismatched disambiguator) - rust-lang#75203 (Make `IntoIterator` lifetime bounds of `&BTreeMap` match with `&HashMap` ) - rust-lang#75227 (Fix ICE when using asm! on an unsupported architecture) Failed merges: r? @ghost
oliver-giersch
commented
Aug 11, 2020
Ok, I am a bit confused by the merge process. So the initial changes have been merged as part of a roll-up, but not that latest commit I've made addressing the latest change requests and neither has the PR itself been merged. |
RalfJung
commented
Aug 11, 2020
@oliver-giersch looks like you pushed something after approval -- in fact even after rollup, so it was not considered. Can you make a new PR with just those remaining changes? |
oliver-giersch
commented
Aug 11, 2020
Got it, I wasn't aware that I wasn't supposed to make changes after approval, will keep that in mind for further contributions. The rollup also occurred only a few minutes before I made the final commit. Should I close this PR now? |
RalfJung
commented
Aug 11, 2020
Yeah it's better to wait for someone to Yes please close this PR and make a new one for what got missed. Great that you noticed this. :) |
…fJung Requested changes to [*mut T|*const T]::set_ptr_value This is a follow-up to PR rust-lang#74774 (tracking issue rust-lang#75091), acting on some change requests made after approval: - adds `#[must_use]` attribute - changes type of `val` pointer argument from `()` to `u8` - adjusts documentation mentioning pointer provenance
I propose the addition of these two functions to
*mut Tand*const T, respectively. The motivation for this is primarily byte-wise pointer arithmetic on (potentially) fat pointers, i.e. for types with aT: ?Sizedbound. A concrete use-case has been discussed in this thread.TL;DR: Currently, byte-wise pointer arithmetic with potentially fat pointers in not possible in either stable or nightly Rust without making assumptions about the layout of fat pointers, which is currently still an implementation detail and not formally stabilized. This PR adds one function to
*mut Tand*const Teach, allowing to circumvent this restriction without exposing any internal implementation details.One possible alternative would be to add specific byte-wise pointer arithmetic functions to the two pointer types in addition to the already existing count-wise functions. However, I feel this fairly niche use case does not warrant adding a whole set of new functions like
add_bytes,offset_bytes,wrapping_offset_bytes, etc. (times two, one for each pointer type) tolibcore.