-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Arc downcast #50836
Arc downcast #50836
Conversation
r? @SimonSapin |
Stability attributes on trait impls don’t really work, so those impls are effectively insta-stable if both the trait and type are stable.
In both cases though, the attribute should still be accurate and say |
OK, I made them
|
r=me on the diff. Let’s also get team sign off on insta-stable APIs:
@rfcbot fcp merge |
@rfcbot fcp merge |
Team member @SimonSapin has proposed to merge this. The next step is review by the rest of the tagged teams: No concerns currently listed. Once a majority of reviewers approve (and none object), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
082e2ba
to
f7d06f8
Compare
@@ -971,6 +972,44 @@ unsafe impl<#[may_dangle] T: ?Sized> Drop for Arc<T> { | |||
} | |||
} | |||
|
|||
impl Arc<Any + Send + Sync> { | |||
#[inline] |
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.
Attributes tend to go below doc comments
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.
This is a copy of the corresponding code in Rc
. I agree it looks strange.
🔔 This is now entering its final comment period, as per the review above. 🔔 |
@bors r+ Thanks! |
📌 Commit f7d06f8 has been approved by |
🔒 Merge conflict |
Implement `is`, `downcast_ref`, `downcast_mut` and `Debug` for `Any + Send + Sync`.
We only need to implement it for `Any + Send + Sync` because in practice that's the only useful combination for `Arc` and `Any`. Implementation for rust-lang#44608 under the `rc_downcast` feature.
This avoids an `unsafe` block in each case.
Make the Any+Send+Sync examples use the right trait bounds, and fix a small whitespace issue.
I rebased onto current master (though I didn't need to resolve any conflicts). |
@bors r+ |
📌 Commit 87c3d7b has been approved by |
Arc downcast Implement `downcast` for `Arc<Any + Send + Sync>` as part of #44608, and gated by the same `rc_downcast` feature. This PR is mostly lightly-edited cut'n'paste. This has two additional changes: - The `downcast` implementation needs `Any + Send + Sync` implementations for `is` and `Debug`, and I added `downcast_ref` and `downcast_mut` for completeness/consistency. (Can these be insta-stabilized?) - At @SimonSapin's suggestion, I converted `Arc` and `Rc` to use `NonNull::cast` to avoid an `unsafe` block in each which tidied things up nicely.
☀️ Test successful - status-appveyor, status-travis |
Should this be tagged |
Yep, thanks @pthariensflame! |
For the |
Implement
downcast
forArc<Any + Send + Sync>
as part of #44608, and gated by the samerc_downcast
feature.This PR is mostly lightly-edited cut'n'paste.
This has two additional changes:
downcast
implementation needsAny + Send + Sync
implementations foris
andDebug
, and I addeddowncast_ref
anddowncast_mut
for completeness/consistency. (Can these be insta-stabilized?)Arc
andRc
to useNonNull::cast
to avoid anunsafe
block in each which tidied things up nicely.