Skip to content

Commit 2919430

Browse files
committed
Add SAFETY comment to downcast_trait_mut
1 parent d9cb965 commit 2919430

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

library/core/src/any.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -931,6 +931,8 @@ pub const fn downcast_trait_mut<
931931
match vtable {
932932
Some(dyn_metadata) => {
933933
let pointer = ptr::from_raw_parts_mut(t, dyn_metadata);
934+
// SAFETY: `t` is a reference to a type, so we know it is valid.
935+
// `dyn_metadata` is a vtable for T, implementing the trait of `U`.
934936
Some(unsafe { &mut *pointer })
935937
}
936938
None => None,

0 commit comments

Comments
 (0)