-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
std: Second pass stabilization for ptr
#20042
Conversation
r? @pcwalton (rust_highfive has picked a reviewer for you, use r? to override) |
r? @aturon |
84e1ac0
to
3bdbde3
Compare
} | ||
|
||
#[inline] | ||
#[unstable = "return value does not necessarily convey all possible \ |
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.
Can you change this to say: Option
is not clearly the right return type, and we may want to tie the return lifetime to a borrow of the raw pointer.
r=me modulo tiny nit |
3bdbde3
to
ad09584
Compare
deleting r+ for now, I'd like to take some more time to analyze https://github.com/Gankro/raw-rs/blob/master/src/rawptr.rs |
CC me |
ad09584
to
6ed5017
Compare
Ok, after thinking about this and talking it over with @gankro, I'm thinking the following:
For now the functionality stabilized here I believe is a subset of the possible future functionality, and I think we can let feedback during the first alpha cycle to drive the rest of what we stabilize in this module. Does that sound ok @gankro? re-r? @aturon |
6ed5017
to
105a2ae
Compare
fn is_not_null(&self) -> bool { !self.is_null() } | ||
/// Returns true if the pointer is not equal to the null pointer. | ||
#[stable] | ||
fn is_not_null(self) -> bool { !self.is_null() } |
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.
Can this be dropped in favor of !p.is_null()
?
r=me modulo nits. |
Sounds okay, but the renames are a back-compat issue, no? |
Neither are being stabilized here, FWIW. |
Not sure if it matters, but they are compiler intrinsics. |
105a2ae
to
e2f88b8
Compare
This commit performs a second pass for stabilization over the `std::ptr` module. The specific actions taken were: * The `RawPtr` trait was renamed to `PtrExt` * The `RawMutPtr` trait was renamed to `MutPtrExt` * The module name `ptr` is now stable. * These functions were all marked `#[stable]` with no modification: * `null` * `null_mut` * `swap` * `replace` * `read` * `write` * `PtrExt::is_null` * `PtrExt::offset` * These functions remain unstable: * `as_ref`, `as_mut` - the return value of an `Option` is not fully expressive as null isn't the only bad value, and it's unclear whether we want to commit to these functions at this time. The reference/lifetime semantics as written are also problematic in how they encourage arbitrary lifetimes. * `zero_memory` - This function is currently not used at all in the distribution, and in general it plays a broader role in the "working with unsafe pointers" story. This story is not yet fully developed, so at this time the function remains unstable for now. * `read_and_zero` - This function remains unstable for largely the same reasons as `zero_memory`. * These functions are now all deprecated: * `PtrExt::null` - call `ptr::null` or `ptr::null_mut` instead. * `PtrExt::to_uint` - use an `as` expression instead. * `PtrExt::is_not_null` - use `!p.is_null()` instead.
e2f88b8
to
54452cd
Compare
This commit performs a second pass for stabilization over the `std::ptr` module. The specific actions taken were: * The `RawPtr` trait was renamed to `PtrExt` * The `RawMutPtr` trait was renamed to `PtrMutExt` * The module name `ptr` is now stable. * These functions were all marked `#[stable]` with no modification: * `null` * `null_mut` * `swap` * `replace` * `read` * `write` * `PtrExt::is_null` * `PtrExt::is_not_null` * `PtrExt::offset` * These functions remain unstable: * `as_ref`, `as_mut` - the return value of an `Option` is not fully expressive as null isn't the only bad value, and it's unclear whether we want to commit to these functions at this time. The reference/lifetime semantics as written are also problematic in how they encourage arbitrary lifetimes. * `zero_memory` - This function is currently not used at all in the distribution, and in general it plays a broader role in the "working with unsafe pointers" story. This story is not yet fully developed, so at this time the function remains unstable for now. * `read_and_zero` - This function remains unstable for largely the same reasons as `zero_memory`. * These functions are now all deprecated: * `PtrExt::null` - call `ptr::null` or `ptr::null_mut` instead. * `PtrExt::to_uint` - use an `as` expression instead.
This commit performs a second pass for stabilization over the
std::ptr
module.The specific actions taken were:
RawPtr
trait was renamed toPtrExt
RawMutPtr
trait was renamed toPtrMutExt
ptr
is now stable.#[stable]
with no modification:null
null_mut
swap
replace
read
write
PtrExt::is_null
PtrExt::is_not_null
PtrExt::offset
as_ref
,as_mut
- the return value of anOption
is not fully expressiveas null isn't the only bad value, and it's unclear
whether we want to commit to these functions at this
time. The reference/lifetime semantics as written are
also problematic in how they encourage arbitrary
lifetimes.
zero_memory
- This function is currently not used at all in thedistribution, and in general it plays a broader role in the
"working with unsafe pointers" story. This story is not yet
fully developed, so at this time the function remains
unstable for now.
read_and_zero
- This function remains unstable for largely the samereasons as
zero_memory
.PtrExt::null
- callptr::null
orptr::null_mut
instead.PtrExt::to_uint
- use anas
expression instead.