Skip to content

Commit 53bb1ca

Browse files
ionicmc-rsgitbot
authored and
gitbot
committed
Fixes safety docs for dyn Any + Send {+ Sync}
1 parent 3c39140 commit 53bb1ca

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

core/src/any.rs

+12-2
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,8 @@ impl dyn Any + Send {
423423
///
424424
/// # Safety
425425
///
426-
/// Same as the method on the type `dyn Any`.
426+
/// The contained value must be of type `T`. Calling this method
427+
/// with the incorrect type is *undefined behavior*.
427428
#[unstable(feature = "downcast_unchecked", issue = "90850")]
428429
#[inline]
429430
pub unsafe fn downcast_ref_unchecked<T: Any>(&self) -> &T {
@@ -451,7 +452,8 @@ impl dyn Any + Send {
451452
///
452453
/// # Safety
453454
///
454-
/// Same as the method on the type `dyn Any`.
455+
/// The contained value must be of type `T`. Calling this method
456+
/// with the incorrect type is *undefined behavior*.
455457
#[unstable(feature = "downcast_unchecked", issue = "90850")]
456458
#[inline]
457459
pub unsafe fn downcast_mut_unchecked<T: Any>(&mut self) -> &mut T {
@@ -552,6 +554,10 @@ impl dyn Any + Send + Sync {
552554
/// assert_eq!(*x.downcast_ref_unchecked::<usize>(), 1);
553555
/// }
554556
/// ```
557+
/// # Safety
558+
///
559+
/// The contained value must be of type `T`. Calling this method
560+
/// with the incorrect type is *undefined behavior*.
555561
#[unstable(feature = "downcast_unchecked", issue = "90850")]
556562
#[inline]
557563
pub unsafe fn downcast_ref_unchecked<T: Any>(&self) -> &T {
@@ -576,6 +582,10 @@ impl dyn Any + Send + Sync {
576582
///
577583
/// assert_eq!(*x.downcast_ref::<usize>().unwrap(), 2);
578584
/// ```
585+
/// # Safety
586+
///
587+
/// The contained value must be of type `T`. Calling this method
588+
/// with the incorrect type is *undefined behavior*.
579589
#[unstable(feature = "downcast_unchecked", issue = "90850")]
580590
#[inline]
581591
pub unsafe fn downcast_mut_unchecked<T: Any>(&mut self) -> &mut T {

0 commit comments

Comments
 (0)