Skip to content

Commit 8d70216

Browse files
committed
auto merge of #17745 : aturon/rust/revert-any-private, r=alexcrichton
[Previously](e5da6a7), the `Any` trait was split into a private portion and an (empty) public portion, in order to hide the implementation strategy used for downcasting. However, the [new rules](e9ad12c) for privacy forbid `AnyPrivate` from actually being private. This patch thus reverts the introduction of `AnyPrivate`. Although this is unlikely to break any real code, it removes a public trait and is therefore a: [breaking-change]
2 parents b5ba2f5 + d007d44 commit 8d70216

File tree

2 files changed

+2
-9
lines changed

2 files changed

+2
-9
lines changed

src/libcore/any.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,20 +91,15 @@ pub enum Void { }
9191
/// Every type with no non-`'static` references implements `Any`, so `Any` can
9292
/// be used as a trait object to emulate the effects dynamic typing.
9393
#[stable]
94-
pub trait Any: AnyPrivate + 'static {}
95-
96-
/// An inner trait to ensure that only this module can call `get_type_id()`.
97-
pub trait AnyPrivate {
94+
pub trait Any: 'static {
9895
/// Get the `TypeId` of `self`
9996
fn get_type_id(&self) -> TypeId;
10097
}
10198

102-
impl<T: 'static> AnyPrivate for T {
99+
impl<T: 'static> Any for T {
103100
fn get_type_id(&self) -> TypeId { TypeId::of::<T>() }
104101
}
105102

106-
impl<T: 'static + AnyPrivate> Any for T {}
107-
108103
///////////////////////////////////////////////////////////////////////////////
109104
// Extension methods for Any trait objects.
110105
// Implemented as three extension traits so that the methods can be generic.

src/test/compile-fail/issue-14366.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,4 @@ fn main() {
1212
let _x = "test" as &::std::any::Any;
1313
//~^ ERROR the trait `core::kinds::Sized` is not implemented for the type `str`
1414
//~^^ NOTE the trait `core::kinds::Sized` must be implemented for the cast to the object type
15-
//~^^^ ERROR the trait `core::kinds::Sized` is not implemented for the type `str`
16-
//~^^^^ NOTE the trait `core::kinds::Sized` must be implemented for the cast to the object type
1715
}

0 commit comments

Comments
 (0)