diff --git a/commons/zenoh-buffers/src/slice.rs b/commons/zenoh-buffers/src/slice.rs index a652c6930e..9b5d72ca51 100644 --- a/commons/zenoh-buffers/src/slice.rs +++ b/commons/zenoh-buffers/src/slice.rs @@ -76,7 +76,7 @@ impl Writer for &mut [u8] { // SAFETY: this doesn't compile with simple assignment because the compiler // doesn't believe that the subslice has the same lifetime as the original slice, // so we transmute to assure it that it does. - *self = unsafe { mem::transmute(lhs) }; + *self = unsafe { mem::transmute::<&mut [u8], &mut [u8]>(lhs) }; // SAFETY: this operation is safe since we check if len is non-zero. Ok(unsafe { NonZeroUsize::new_unchecked(len) }) @@ -98,7 +98,7 @@ impl Writer for &mut [u8] { // SAFETY: this doesn't compile with simple assignment because the compiler // doesn't believe that the subslice has the same lifetime as the original slice, // so we transmute to assure it that it does. - *self = unsafe { mem::transmute(lhs) }; + *self = unsafe { mem::transmute::<&mut [u8], &mut [u8]>(lhs) }; Ok(()) } @@ -122,7 +122,7 @@ impl Writer for &mut [u8] { // SAFETY: this doesn't compile with simple assignment because the compiler // doesn't believe that the subslice has the same lifetime as the original slice, // so we transmute to assure it that it does. - *self = unsafe { mem::transmute(s) }; + *self = unsafe { mem::transmute::<&mut [u8], &mut [u8]>(s) }; NonZeroUsize::new(len).ok_or(DidntWrite) } diff --git a/commons/zenoh-config/src/lib.rs b/commons/zenoh-config/src/lib.rs index c54d75a82a..7732a5bbc0 100644 --- a/commons/zenoh-config/src/lib.rs +++ b/commons/zenoh-config/src/lib.rs @@ -1086,7 +1086,11 @@ impl PluginsConfig { for next in split { match remove_from { Value::Object(o) => match o.get_mut(current) { - Some(v) => unsafe { remove_from = std::mem::transmute(v) }, + Some(v) => { + remove_from = unsafe { + std::mem::transmute::<&mut serde_json::Value, &mut serde_json::Value>(v) + } + } None => bail!("{:?} has no {} property", o, current), }, Value::Array(a) => { diff --git a/commons/zenoh-keyexpr/src/keyexpr_tree/arc_tree.rs b/commons/zenoh-keyexpr/src/keyexpr_tree/arc_tree.rs index dfb7e68261..fe2640c604 100644 --- a/commons/zenoh-keyexpr/src/keyexpr_tree/arc_tree.rs +++ b/commons/zenoh-keyexpr/src/keyexpr_tree/arc_tree.rs @@ -159,8 +159,11 @@ where } // tags{ketree.arc.node.mut} fn node_mut(&'a self, token: &'a mut Token, at: &keyexpr) -> Option { - self.node(unsafe { core::mem::transmute(&*token) }, at) - .map(|(node, _)| (node, token)) + self.node( + unsafe { core::mem::transmute::<&Token, &Token>(&*token) }, + at, + ) + .map(|(node, _)| (node, token)) } // tags{ketree.arc.node.or_create} fn node_or_create(&'a self, token: &'a mut Token, at: &keyexpr) -> Self::NodeMut { @@ -236,7 +239,9 @@ where fn tree_iter_mut(&'a self, token: &'a mut Token) -> Self::TreeIterMut { let inner = ketree_borrow(&self.inner, token); TokenPacker { - iter: TreeIter::new(unsafe { core::mem::transmute(&inner.children) }), + iter: TreeIter::new(unsafe { + core::mem::transmute::<&Children::Assoc, &Children::Assoc>(&inner.children) + }), token, } } @@ -288,7 +293,12 @@ where let inner = ketree_borrow(&self.inner, token); if inner.wildness.get() || key.is_wild() { IterOrOption::Iter(TokenPacker { - iter: Intersection::new(unsafe { core::mem::transmute(&inner.children) }, key), + iter: Intersection::new( + unsafe { + core::mem::transmute::<&Children::Assoc, &Children::Assoc>(&inner.children) + }, + key, + ), token, }) } else { @@ -340,7 +350,10 @@ where if inner.wildness.get() || key.is_wild() { unsafe { IterOrOption::Iter(TokenPacker { - iter: Inclusion::new(core::mem::transmute(&inner.children), key), + iter: Inclusion::new( + core::mem::transmute::<&Children::Assoc, &Children::Assoc>(&inner.children), + key, + ), token, }) } @@ -393,7 +406,10 @@ where if inner.wildness.get() || key.is_wild() { unsafe { IterOrOption::Iter(TokenPacker { - iter: Includer::new(core::mem::transmute(&inner.children), key), + iter: Includer::new( + core::mem::transmute::<&Children::Assoc, &Children::Assoc>(&inner.children), + key, + ), token, }) } diff --git a/commons/zenoh-keyexpr/src/keyexpr_tree/box_tree.rs b/commons/zenoh-keyexpr/src/keyexpr_tree/box_tree.rs index 67777aaa90..aed873f51a 100644 --- a/commons/zenoh-keyexpr/src/keyexpr_tree/box_tree.rs +++ b/commons/zenoh-keyexpr/src/keyexpr_tree/box_tree.rs @@ -157,7 +157,7 @@ where if !node.children.is_empty() { node.weight.take() } else { - let chunk = unsafe { core::mem::transmute::<_, &keyexpr>(node.chunk()) }; + let chunk = unsafe { core::mem::transmute::<&keyexpr, &keyexpr>(node.chunk()) }; match node.parent { None => &mut self.children, Some(parent) => unsafe { &mut (*parent.as_ptr()).children }, diff --git a/commons/zenoh-keyexpr/src/keyexpr_tree/traits/mod.rs b/commons/zenoh-keyexpr/src/keyexpr_tree/traits/mod.rs index cee2bd9162..ed3f36a371 100644 --- a/commons/zenoh-keyexpr/src/keyexpr_tree/traits/mod.rs +++ b/commons/zenoh-keyexpr/src/keyexpr_tree/traits/mod.rs @@ -54,8 +54,10 @@ pub trait IKeyExprTree<'a, Weight> { Self::TreeIterItem: AsNode>, { self.tree_iter().filter_map(|node| { - unsafe { core::mem::transmute::<_, Option<&Weight>>(node.as_node().weight()) } - .map(|w| (node.as_node().keyexpr(), w)) + unsafe { + core::mem::transmute::, Option<&Weight>>(node.as_node().weight()) + } + .map(|w| (node.as_node().keyexpr(), w)) }) } diff --git a/commons/zenoh-protocol/src/core/encoding.rs b/commons/zenoh-protocol/src/core/encoding.rs index b0b089d9b3..8132729c58 100644 --- a/commons/zenoh-protocol/src/core/encoding.rs +++ b/commons/zenoh-protocol/src/core/encoding.rs @@ -89,7 +89,7 @@ impl TryFrom for KnownEncoding { type Error = ZError; fn try_from(value: u8) -> Result { if value < consts::MIMES.len() as u8 + 1 { - Ok(unsafe { mem::transmute(value) }) + Ok(unsafe { mem::transmute::(value) }) } else { Err(zerror!("Unknown encoding")) } @@ -213,9 +213,14 @@ impl From<&'static str> for Encoding { for (i, v) in consts::MIMES.iter().enumerate().skip(1) { if let Some(suffix) = s.strip_prefix(v) { if suffix.is_empty() { - return Encoding::Exact(unsafe { mem::transmute(i as u8) }); + return Encoding::Exact(unsafe { + mem::transmute::(i as u8) + }); } else { - return Encoding::WithSuffix(unsafe { mem::transmute(i as u8) }, suffix.into()); + return Encoding::WithSuffix( + unsafe { mem::transmute::(i as u8) }, + suffix.into(), + ); } } } @@ -233,9 +238,14 @@ impl From for Encoding { if s.starts_with(v) { s.replace_range(..v.len(), ""); if s.is_empty() { - return Encoding::Exact(unsafe { mem::transmute(i as u8) }); + return Encoding::Exact(unsafe { + mem::transmute::(i as u8) + }); } else { - return Encoding::WithSuffix(unsafe { mem::transmute(i as u8) }, s.into()); + return Encoding::WithSuffix( + unsafe { mem::transmute::(i as u8) }, + s.into(), + ); } } }