-
Notifications
You must be signed in to change notification settings - Fork 13k
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: Stabilize TypeId and tweak BoxAny #21165
Conversation
r? @aturon |
r? @aturon (rust_highfive has picked a reviewer for you, use r? to override) |
/// printing, and showing. | ||
/// | ||
/// A `TypeId` is currently only available for types which ascribe to `'static`, | ||
/// but this limitatoin may be removed in the future. |
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.
Typo limitation
5a234b8
to
d72e978
Compare
OK, I'm happy with this, but want to get @nikomatsakis's opinion as well. |
/// instantiated with | ||
#[cfg(not(stage0))] | ||
#[stable] | ||
pub fn of<T: ?Sized + 'static>() -> TypeId { |
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.
So obviously the key question is this function, right? I'm roughly willing to go with this, but I'd like to get a better understanding of whether we could get by with some kind of bound here.
On Thu, Jan 15, 2015 at 10:51:22AM -0800, Aaron Turon wrote:
After discussing with @reem in IRC, it seems like we want to move to a
@flaper87 is actually pretty close to having the In the meantime it might make sense to keep |
d72e978
to
80d73e9
Compare
r? @aturon I've marked |
Sidenote: the (currently stable) blanket impl for |
It will actually require a |
This commit aims to stabilize the `TypeId` abstraction by moving it out of the `intrinsics` module into the `any` module of the standard library. Specifically, * `TypeId` is now defined at `std::any::TypeId` * `TypeId::hash` has been removed in favor of an implementation of `Hash`. This commit also performs a final pass over the `any` module, confirming the following: * `Any::get_type_id` remains unstable as *usage* of the `Any` trait will likely never require this, and the `Any` trait does not need to be implemented for any other types. As a result, this implementation detail can remain unstable until associated statics are implemented. * `Any::downcast_ref` is now stable * `Any::downcast_mut` is now stable * `BoxAny` remains unstable. While a direct impl on `Box<Any>` is allowed today it does not allow downcasting of trait objects like `Box<Any + Send>` (those returned from `Thread::join`). This is covered by #18737. * `BoxAny::downcast` is now stable.
@bors: retry |
80d73e9
to
e1e0450
Compare
@bors r=aturon e1e0450 |
This commit aims to stabilize the `TypeId` abstraction by moving it out of the `intrinsics` module into the `any` module of the standard library. Specifically, * `TypeId` is now defined at `std::any::TypeId` * `TypeId::hash` has been removed in favor of an implementation of `Hash`. This commit also performs a final pass over the `any` module, confirming the following: * `Any::get_type_id` remains unstable as *usage* of the `Any` trait will likely never require this, and the `Any` trait does not need to be implemented for any other types. As a result, this implementation detail can remain unstable until associated statics are implemented. * `Any::downcast_ref` is now stable * `Any::downcast_mut` is now stable * `BoxAny` remains unstable. While a direct impl on `Box<Any>` is allowed today it does not allow downcasting of trait objects like `Box<Any + Send>` (those returned from `Thread::join`). This is covered by rust-lang#18737. * `BoxAny::downcast` is now stable.
e1e0450
to
70f7165
Compare
@bors: r=aturon 70f165 |
🙀 You have the wrong number! Please try again with |
This commit aims to stabilize the `TypeId` abstraction by moving it out of the `intrinsics` module into the `any` module of the standard library. Specifically, * `TypeId` is now defined at `std::any::TypeId` * `TypeId::hash` has been removed in favor of an implementation of `Hash`. This commit also performs a final pass over the `any` module, confirming the following: * `Any::get_type_id` remains unstable as *usage* of the `Any` trait will likely never require this, and the `Any` trait does not need to be implemented for any other types. As a result, this implementation detail can remain unstable until associated statics are implemented. * `Any::downcast_ref` is now stable * `Any::downcast_mut` is now stable * `BoxAny` remains unstable. While a direct impl on `Box<Any>` is allowed today it does not allow downcasting of trait objects like `Box<Any + Send>` (those returned from `Thread::join`). This is covered by #18737. * `BoxAny::downcast` is now stable.
This commit aims to stabilize the
TypeId
abstraction by moving it out of theintrinsics
module into theany
module of the standard library. Specifically,TypeId
is now defined atstd::any::TypeId
TypeId::hash
has been removed in favor of an implementation ofHash
.This commit also performs a final pass over the
any
module, confirming thefollowing:
Any::get_type_id
remains unstable as usage of theAny
trait will likelynever require this, and the
Any
trait does not need to be implemented forany other types. As a result, this implementation detail can remain unstable
until associated statics are implemented.
Any::downcast_ref
is now stableAny::downcast_mut
is now stableBoxAny
remains unstable. While a direct impl onBox<Any>
is allowed todayit does not allow downcasting of trait objects like
Box<Any + Send>
(thosereturned from
Thread::join
). This is covered by Replace current quasi-subtyping relationship for object types with coercions #18737.BoxAny::downcast
is now stable.