Skip to content

Commit 217f8fb

Browse files
committed
Revert borked changes in last commit.
1 parent cd44b3d commit 217f8fb

File tree

4 files changed

+15
-14
lines changed

4 files changed

+15
-14
lines changed

src/liballoc/boxed.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ impl From<Box<str>> for Box<[u8]> {
446446
}
447447
}
448448

449-
impl Box<Any> {
449+
impl Box<dyn Any> {
450450
#[inline]
451451
#[stable(feature = "rust1", since = "1.0.0")]
452452
/// Attempt to downcast the box to a concrete type.
@@ -468,10 +468,10 @@ impl Box<Any> {
468468
/// print_if_string(Box::new(0i8));
469469
/// }
470470
/// ```
471-
pub fn downcast<T: Any>(self) -> Result<Box<T>, Box<Any>> {
471+
pub fn downcast<T: Any>(self) -> Result<Box<T>, Box<dyn Any>> {
472472
if self.is::<T>() {
473473
unsafe {
474-
let raw: *mut Any = Box::into_raw(self);
474+
let raw: *mut dyn Any = Box::into_raw(self);
475475
Ok(Box::from_raw(raw as *mut T))
476476
}
477477
} else {
@@ -480,7 +480,7 @@ impl Box<Any> {
480480
}
481481
}
482482

483-
impl Box<Any + Send> {
483+
impl Box<dyn Any + Send> {
484484
#[inline]
485485
#[stable(feature = "rust1", since = "1.0.0")]
486486
/// Attempt to downcast the box to a concrete type.
@@ -502,10 +502,10 @@ impl Box<Any + Send> {
502502
/// print_if_string(Box::new(0i8));
503503
/// }
504504
/// ```
505-
pub fn downcast<T: Any>(self) -> Result<Box<T>, Box<Any + Send>> {
506-
<Box<Any>>::downcast(self).map_err(|s| unsafe {
505+
pub fn downcast<T: Any>(self) -> Result<Box<T>, Box<dyn Any + Send>> {
506+
<Box<dyn Any>>::downcast(self).map_err(|s| unsafe {
507507
// reapply the Send marker
508-
Box::from_raw(Box::into_raw(s) as *mut (Any + Send))
508+
Box::from_raw(Box::into_raw(s) as *mut (dyn Any + Send))
509509
})
510510
}
511511
}
@@ -643,7 +643,7 @@ impl<A, F> FnBox<A> for F
643643

644644
#[unstable(feature = "fnbox",
645645
reason = "will be deprecated if and when `Box<FnOnce>` becomes usable", issue = "28796")]
646-
impl<'a, A, R> FnOnce<A> for Box<FnBox<A, Output = R> + 'a> {
646+
impl<'a, A, R> FnOnce<A> for Box<dyn FnBox<A, Output = R> + 'a> {
647647
type Output = R;
648648

649649
extern "rust-call" fn call_once(self, args: A) -> R {
@@ -653,7 +653,7 @@ impl<'a, A, R> FnOnce<A> for Box<FnBox<A, Output = R> + 'a> {
653653

654654
#[unstable(feature = "fnbox",
655655
reason = "will be deprecated if and when `Box<FnOnce>` becomes usable", issue = "28796")]
656-
impl<'a, A, R> FnOnce<A> for Box<FnBox<A, Output = R> + Send + 'a> {
656+
impl<'a, A, R> FnOnce<A> for Box<dyn FnBox<A, Output = R> + Send + 'a> {
657657
type Output = R;
658658

659659
extern "rust-call" fn call_once(self, args: A) -> R {

src/liballoc/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
test(no_crate_inject, attr(allow(unused_variables), deny(warnings))))]
7373
#![no_std]
7474
#![needs_allocator]
75+
#![deny(bare_trait_objects)]
7576
#![deny(missing_debug_implementations)]
7677

7778
#![cfg_attr(test, allow(deprecated))] // rand

src/liballoc/rc.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,7 @@ impl<T: Clone> Rc<T> {
618618
}
619619
}
620620

621-
impl Rc<Any> {
621+
impl Rc<dyn Any> {
622622
#[inline]
623623
#[stable(feature = "rc_downcast", since = "1.29.0")]
624624
/// Attempt to downcast the `Rc<Any>` to a concrete type.
@@ -641,7 +641,7 @@ impl Rc<Any> {
641641
/// print_if_string(Rc::new(0i8));
642642
/// }
643643
/// ```
644-
pub fn downcast<T: Any>(self) -> Result<Rc<T>, Rc<Any>> {
644+
pub fn downcast<T: Any>(self) -> Result<Rc<T>, Rc<dyn Any>> {
645645
if (*self).is::<T>() {
646646
let ptr = self.ptr.cast::<RcBox<T>>();
647647
forget(self);

src/liballoc/sync.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -978,18 +978,18 @@ unsafe impl<#[may_dangle] T: ?Sized> Drop for Arc<T> {
978978
}
979979
}
980980

981-
impl Arc<Any + Send + Sync> {
981+
impl Arc<dyn Any + Send + Sync> {
982982
#[inline]
983983
#[stable(feature = "rc_downcast", since = "1.29.0")]
984-
/// Attempt to downcast the `Arc<Any + Send + Sync>` to a concrete type.
984+
/// Attempt to downcast the `Arc<dyn Any + Send + Sync>` to a concrete type.
985985
///
986986
/// # Examples
987987
///
988988
/// ```
989989
/// use std::any::Any;
990990
/// use std::sync::Arc;
991991
///
992-
/// fn print_if_string(value: Arc<Any + Send + Sync>) {
992+
/// fn print_if_string(value: Arc<dyn Any + Send + Sync>) {
993993
/// if let Ok(string) = value.downcast::<String>() {
994994
/// println!("String ({}): {}", string.len(), string);
995995
/// }

0 commit comments

Comments
 (0)