Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upRename std::ptr::Shared to NonNull and stabilize it #46952
Conversation
rust-highfive
assigned
KodrAus
Dec 22, 2017
This comment has been minimized.
This comment has been minimized.
|
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @KodrAus (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
This comment has been minimized.
This comment has been minimized.
|
That proposal so far has got a couple thumbs up and no negative comment or reaction. Maybe @rust-lang/libs can discuss and do a FCP in this thread? |
SimonSapin
referenced this pull request
Dec 22, 2017
Closed
Tracking issue for `NonZero`/`Unique`/`Shared` stabilization #27730
SimonSapin
force-pushed the
SimonSapin:nonnull
branch
from
92b6403
to
ed13cc0
Dec 22, 2017
kennytm
added
S-waiting-on-team
T-libs
labels
Dec 22, 2017
joshlf
referenced this pull request
Dec 22, 2017
Closed
Switch object-alloc and dependents to NonNull raw pointers #140
This comment has been minimized.
This comment has been minimized.
|
Bikeshed: |
This comment has been minimized.
This comment has been minimized.
|
@leodasvacas What’s your preferred shed color? By your use of lower case I assume you mean in the |
This comment has been minimized.
This comment has been minimized.
|
Sorry for being unclear, I just prefer |
This comment has been minimized.
This comment has been minimized.
|
Ok. So the methods would be |
This comment has been minimized.
This comment has been minimized.
|
|
SimonSapin
added a commit
to SimonSapin/nomicon
that referenced
this pull request
Dec 22, 2017
SimonSapin
referenced this pull request
Dec 22, 2017
Merged
The `unique` feature is renamed `ptr_internals` #48
SimonSapin
force-pushed the
SimonSapin:nonnull
branch
from
ed13cc0
to
5245a61
Dec 22, 2017
SimonSapin
referenced this pull request
Dec 22, 2017
Merged
The `unique` feature is renamed `ptr_internals` #49
SimonSapin
force-pushed the
SimonSapin:nonnull
branch
from
5245a61
to
06b7945
Dec 22, 2017
This comment has been minimized.
This comment has been minimized.
|
I’ve pushed a commit to rename |
This comment has been minimized.
This comment has been minimized.
|
But That said, riding in the
use ::std::ptr::NotNull;
use ::core::nonzero::Nonzero;
fn foo() {
let raw = NotNull::new(&0).unwrap();
let _ = Box::from_not_null_raw(raw);
}or leaning the other way, we could have |
This comment has been minimized.
This comment has been minimized.
|
Besides naming, this is also a good time to reconsider whether I added So I think there's value in keeping this conversion in some form. It could be an impl of the
|
kennytm
referenced this pull request
Dec 27, 2017
Closed
Implement Debug for ptr::Shared and ptr::Unique. #46792
kennytm
reviewed
Dec 27, 2017
| @@ -2331,8 +2331,9 @@ impl<T: ?Sized> PartialOrd for *mut T { | |||
| /// Unlike `*mut T`, `Unique<T>` is covariant over `T`. This should always be correct | |||
| /// for any type which upholds Unique's aliasing requirements. | |||
| #[allow(missing_debug_implementations)] | |||
This comment has been minimized.
This comment has been minimized.
goodmanjonathan
reviewed
Dec 27, 2017
| fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||
| fmt::Pointer::fmt(&self.as_ptr(), f) | ||
| } | ||
| } | ||
|
|
||
| #[unstable(feature = "shared", issue = "27730")] | ||
| impl<T: ?Sized> From<Unique<T>> for Shared<T> { | ||
| #[stable(feature = "nonnull", since = "1.24.0")] |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
SimonSapin
Dec 27, 2017
Author
Contributor
Maybe. Even if this impl is usable, it can’t be used if you can’t get a Unique<T> value in the first place on stable Rust. And anyway, IIRC stability attributes don’t work on impl blocks at the moment. (They’re insta-stable if the relevant traits and types are stable.)
This comment has been minimized.
This comment has been minimized.
goodmanjonathan
Dec 27, 2017
Contributor
Right, I was just afraid it might have other effects (e.g. like showing up in rustdoc). If not, I'm fine either way.
This comment has been minimized.
This comment has been minimized.
SimonSapin
Dec 27, 2017
Author
Contributor
Unstable impls are visible in rustdoc too: https://doc.rust-lang.org/std/ptr/struct.Shared.html#impl-From%3CUnique%3CT%3E%3E
This comment has been minimized.
This comment has been minimized.
SimonSapin
force-pushed the
SimonSapin:nonnull
branch
from
588ea9e
to
f91240e
Dec 27, 2017
SimonSapin
added a commit
to SimonSapin/rust
that referenced
this pull request
Dec 27, 2017
This comment has been minimized.
This comment has been minimized.
|
This comment has been minimized.
This comment has been minimized.
However we already have |
This comment has been minimized.
This comment has been minimized.
|
Pushed another commit (that we can remove from the PR if it turns out problematic) that replaces |
This comment has been minimized.
This comment has been minimized.
|
I don't think it's a good idea to reintroduce an |
SimonSapin
added some commits
Jan 9, 2018
SimonSapin
force-pushed the
SimonSapin:nonnull
branch
from
2cf5c6a
to
602a445
Jan 20, 2018
This comment has been minimized.
This comment has been minimized.
Sigh. This PR changes the expected result of an unrelated test (rustdoc seach results) that was added after the PR was created. Should be fixed now: diff --git a/src/test/rustdoc-js/from_u.js b/src/test/rustdoc-js/from_u.js
index 920620a9ae..0296788f7a 100644
--- a/src/test/rustdoc-js/from_u.js
+++ b/src/test/rustdoc-js/from_u.js
@@ -15,7 +15,6 @@ const EXPECTED = {
{ 'path': 'std::char', 'name': 'from_u32' },
{ 'path': 'std::str', 'name': 'from_utf8' },
{ 'path': 'std::string::String', 'name': 'from_utf8' },
- { 'path': 'std::boxed::Box', 'name': 'from_unique' },
{ 'path': 'std::i32', 'name': 'from_unsigned' },
{ 'path': 'std::i128', 'name': 'from_unsigned' },
], |
This comment has been minimized.
This comment has been minimized.
|
@bors r=alexcrichton |
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
bors
added a commit
that referenced
this pull request
Jan 20, 2018
This comment has been minimized.
This comment has been minimized.
|
|
bors
merged commit 602a445
into
rust-lang:master
Jan 20, 2018
bors
referenced this pull request
Jan 20, 2018
Closed
[proof of concept] give String support for CoW wrapping of literals #46993
This comment has been minimized.
This comment has been minimized.
|
\o/ you did it! |
bluss
added
the
relnotes
label
Jan 20, 2018
SimonSapin
deleted the
SimonSapin:nonnull
branch
Jan 20, 2018
This comment has been minimized.
This comment has been minimized.
|
Stop me if I should bring this up in a new issue, but how do folks feel about adding a conversion from |
This comment has been minimized.
This comment has been minimized.
|
@joshlf It should probably be a new issue (or a PR ;)) but I’ve been thinking the same when considering whether every |
SimonSapin
referenced this pull request
Jan 21, 2018
Merged
Add some APIs to ptr::NonNull and fix `since` attributes #47631
This comment has been minimized.
This comment has been minimized.
|
Would've submitted a PR, but I see you've beaten me to it :)
…On Jan 20, 2018 11:34 PM, "Simon Sapin" ***@***.***> wrote:
@joshlf <https://github.com/joshlf> It should probably be a new issue (or
a PR ;)) but I’ve been thinking the same when considering whether every *mut
u8 in return types in the Alloc trait should be NonNull<u8> instead. So
for though I think the need is less pressing as long as there are few APIs
that return NonNull<_>: if you create it from a raw pointer anyway, you
can cast with as beforehand.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#46952 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AA_2L_mZdcvSPvPHjYXaz1V6BSo1rguWks5tMuiagaJpZM4RLVAQ>
.
|
This comment has been minimized.
This comment has been minimized.
|
Oops, I forgot to comment here about it. Yeah, since I was making other changes… :) |
SimonSapin commentedDec 22, 2017
•
edited
This implements the changes proposed at #27730 (comment):