Skip to content

Commit 852c332

Browse files
Safety comment
Co-authored-by: Oli Scherer <[email protected]>
1 parent db579d3 commit 852c332

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
@@ -910,6 +910,8 @@ pub const fn downcast_trait<
910910
match vtable {
911911
Some(dyn_metadata) => {
912912
let pointer = ptr::from_raw_parts(t, dyn_metadata);
913+
// SAFETY: `t` is a reference to a type, so we know it is valid.
914+
// `dyn_metadata` is a vtable for T, implementing the trait of `U`.
913915
Some(unsafe { &*pointer })
914916
}
915917
None => None,

0 commit comments

Comments
 (0)