@@ -424,7 +424,7 @@ where
424424 while !node. is_null ( ) {
425425 // SAFETY: By the type invariant of `Self`, all non-null `rb_node` pointers stored in `self`
426426 // point to the links field of `Node<K, V>` objects.
427- let this = unsafe { container_of ! ( node, Node <K , V >, links) } . cast_mut ( ) ;
427+ let this = unsafe { container_of ! ( node, Node <K , V >, links) } ;
428428 // SAFETY: `this` is a non-null node so it is valid by the type invariants.
429429 let this_key = unsafe { & ( * this) . key } ;
430430 // SAFETY: `node` is a non-null node so it is valid by the type invariants.
@@ -496,7 +496,7 @@ impl<K, V> Drop for RBTree<K, V> {
496496 // but it is not observable. The loop invariant is still maintained.
497497
498498 // SAFETY: `this` is valid per the loop invariant.
499- unsafe { drop ( KBox :: from_raw ( this. cast_mut ( ) ) ) } ;
499+ unsafe { drop ( KBox :: from_raw ( this) ) } ;
500500 }
501501 }
502502}
@@ -761,7 +761,7 @@ impl<'a, K, V> Cursor<'a, K, V> {
761761 let next = self . get_neighbor_raw ( Direction :: Next ) ;
762762 // SAFETY: By the type invariant of `Self`, all non-null `rb_node` pointers stored in `self`
763763 // point to the links field of `Node<K, V>` objects.
764- let this = unsafe { container_of ! ( self . current. as_ptr( ) , Node <K , V >, links) } . cast_mut ( ) ;
764+ let this = unsafe { container_of ! ( self . current. as_ptr( ) , Node <K , V >, links) } ;
765765 // SAFETY: `this` is valid by the type invariants as described above.
766766 let node = unsafe { KBox :: from_raw ( this) } ;
767767 let node = RBTreeNode { node } ;
@@ -806,7 +806,7 @@ impl<'a, K, V> Cursor<'a, K, V> {
806806 unsafe { bindings:: rb_erase ( neighbor, addr_of_mut ! ( self . tree. root) ) } ;
807807 // SAFETY: By the type invariant of `Self`, all non-null `rb_node` pointers stored in `self`
808808 // point to the links field of `Node<K, V>` objects.
809- let this = unsafe { container_of ! ( neighbor, Node <K , V >, links) } . cast_mut ( ) ;
809+ let this = unsafe { container_of ! ( neighbor, Node <K , V >, links) } ;
810810 // SAFETY: `this` is valid by the type invariants as described above.
811811 let node = unsafe { KBox :: from_raw ( this) } ;
812812 return Some ( RBTreeNode { node } ) ;
@@ -912,7 +912,7 @@ impl<'a, K, V> Cursor<'a, K, V> {
912912 unsafe fn to_key_value_raw < ' b > ( node : NonNull < bindings:: rb_node > ) -> ( & ' b K , * mut V ) {
913913 // SAFETY: By the type invariant of `Self`, all non-null `rb_node` pointers stored in `self`
914914 // point to the links field of `Node<K, V>` objects.
915- let this = unsafe { container_of ! ( node. as_ptr( ) , Node <K , V >, links) } . cast_mut ( ) ;
915+ let this = unsafe { container_of ! ( node. as_ptr( ) , Node <K , V >, links) } ;
916916 // SAFETY: The passed `node` is the current node or a non-null neighbor,
917917 // thus `this` is valid by the type invariants.
918918 let k = unsafe { & ( * this) . key } ;
@@ -1021,7 +1021,7 @@ impl<K, V> Iterator for IterRaw<K, V> {
10211021
10221022 // SAFETY: By the type invariant of `IterRaw`, `self.next` is a valid node in an `RBTree`,
10231023 // and by the type invariant of `RBTree`, all nodes point to the links field of `Node<K, V>` objects.
1024- let cur = unsafe { container_of ! ( self . next, Node <K , V >, links) } . cast_mut ( ) ;
1024+ let cur = unsafe { container_of ! ( self . next, Node <K , V >, links) } ;
10251025
10261026 // SAFETY: `self.next` is a valid tree node by the type invariants.
10271027 self . next = unsafe { bindings:: rb_next ( self . next ) } ;
@@ -1216,7 +1216,7 @@ impl<'a, K, V> OccupiedEntry<'a, K, V> {
12161216 // SAFETY:
12171217 // - `self.node_links` is a valid pointer to a node in the tree.
12181218 // - We have exclusive access to the underlying tree, and can thus give out a mutable reference.
1219- unsafe { & mut ( * ( container_of ! ( self . node_links, Node <K , V >, links) . cast_mut ( ) ) ) . value }
1219+ unsafe { & mut ( * ( container_of ! ( self . node_links, Node <K , V >, links) ) ) . value }
12201220 }
12211221
12221222 /// Converts the entry into a mutable reference to its value.
@@ -1226,7 +1226,7 @@ impl<'a, K, V> OccupiedEntry<'a, K, V> {
12261226 // SAFETY:
12271227 // - `self.node_links` is a valid pointer to a node in the tree.
12281228 // - This consumes the `&'a mut RBTree<K, V>`, therefore it can give out a mutable reference that lives for `'a`.
1229- unsafe { & mut ( * ( container_of ! ( self . node_links, Node <K , V >, links) . cast_mut ( ) ) ) . value }
1229+ unsafe { & mut ( * ( container_of ! ( self . node_links, Node <K , V >, links) ) ) . value }
12301230 }
12311231
12321232 /// Remove this entry from the [`RBTree`].
@@ -1239,9 +1239,7 @@ impl<'a, K, V> OccupiedEntry<'a, K, V> {
12391239 RBTreeNode {
12401240 // SAFETY: The node was a node in the tree, but we removed it, so we can convert it
12411241 // back into a box.
1242- node : unsafe {
1243- KBox :: from_raw ( container_of ! ( self . node_links, Node <K , V >, links) . cast_mut ( ) )
1244- } ,
1242+ node : unsafe { KBox :: from_raw ( container_of ! ( self . node_links, Node <K , V >, links) ) } ,
12451243 }
12461244 }
12471245
@@ -1272,8 +1270,7 @@ impl<'a, K, V> OccupiedEntry<'a, K, V> {
12721270 // SAFETY:
12731271 // - `self.node_ptr` produces a valid pointer to a node in the tree.
12741272 // - Now that we removed this entry from the tree, we can convert the node to a box.
1275- let old_node =
1276- unsafe { KBox :: from_raw ( container_of ! ( self . node_links, Node <K , V >, links) . cast_mut ( ) ) } ;
1273+ let old_node = unsafe { KBox :: from_raw ( container_of ! ( self . node_links, Node <K , V >, links) ) } ;
12771274
12781275 RBTreeNode { node : old_node }
12791276 }
0 commit comments