summaryrefslogtreecommitdiff
path: root/serde_v8/serializable.rs
diff options
context:
space:
mode:
authorLuca Casonato <hello@lcas.dev>2022-06-26 00:13:24 +0200
committerGitHub <noreply@github.com>2022-06-26 00:13:24 +0200
commit8d82ba729937baf83011354242cabc3d50c13dc2 (patch)
tree3e8c4d87986338639eeef4a76543e4335020262c /serde_v8/serializable.rs
parent38505db39137f33bfdb942658ea892a617ac0980 (diff)
build: require safety comments on unsafe code (#13870)
Co-authored-by: Bartek IwaƄczuk <biwanczuk@gmail.com> Co-authored-by: Divy Srivastava <dj.srivastava23@gmail.com>
Diffstat (limited to 'serde_v8/serializable.rs')
-rw-r--r--serde_v8/serializable.rs2
1 files changed, 2 insertions, 0 deletions
diff --git a/serde_v8/serializable.rs b/serde_v8/serializable.rs
index a724f300e..abde544c7 100644
--- a/serde_v8/serializable.rs
+++ b/serde_v8/serializable.rs
@@ -97,6 +97,8 @@ impl<T: serde::Serialize + 'static> From<T> for SerializablePkg {
fn from(x: T) -> Self {
#[inline(always)]
fn tc<T, U>(src: T) -> U {
+ // SAFETY: the caller has ensured via the TypeId that the T and U types
+ // are the same.
let x = unsafe { transmute_copy(&src) };
std::mem::forget(src);
x