Skip to content

Commit c55d874

Browse files
ivarflakstadizagawd
authored andcommitted
Add SAFETY comment to downcast_trait_mut
1 parent f6b6930 commit c55d874

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
@@ -941,6 +941,8 @@ pub const fn downcast_trait_mut<
941941
match vtable {
942942
Some(dyn_metadata) => {
943943
let pointer = ptr::from_raw_parts_mut(t, dyn_metadata);
944+
// SAFETY: `t` is a reference to a type, so we know it is valid.
945+
// `dyn_metadata` is a vtable for T, implementing the trait of `U`.
944946
Some(unsafe { &mut *pointer })
945947
}
946948
None => None,

0 commit comments

Comments
 (0)