Skip to content

Commit 0348628

Browse files
ivarflakstadoli-obk
authored andcommitted
Safety comment
Co-authored-by: Oli Scherer <github35764891676564198441@oli-obk.de>
1 parent e2cad12 commit 0348628

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
@@ -920,6 +920,8 @@ pub const fn downcast_trait<
920920
match vtable {
921921
Some(dyn_metadata) => {
922922
let pointer = ptr::from_raw_parts(t, dyn_metadata);
923+
// SAFETY: `t` is a reference to a type, so we know it is valid.
924+
// `dyn_metadata` is a vtable for T, implementing the trait of `U`.
923925
Some(unsafe { &*pointer })
924926
}
925927
None => None,

0 commit comments

Comments
 (0)