Skip to content

Commit 551bfef

Browse files
authored
Unrolled build for rust-lang#134662
Rollup merge of rust-lang#134662 - ionicmc-rs:any-safety-docs, r=Amanieu Fix safety docs for `dyn Any + Send {+ Sync}` Fixes the `# Safety` docs for `dyn Any + Send`'s `downcast_{mut/ref}_unchecked` to show the direct instructions , where previously the would tell the user to find the docs on `dyn Any` themselves. This also adds them for `downcast_{mut/ref}_unchecked` on `dyn Any + Send + Sync`
2 parents f334342 + 5a8d970 commit 551bfef

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

library/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)