Skip to content

Use Box::assume_init in RBTreeNodeReservation::into_node once/if new_uninit is stabilised. #401

Open

Description

@wedsonaf
No description provided.

Activity

  1. GuilhermeGiacomoSimoes commented on Jan 11, 2025

    @GuilhermeGiacomoSimoes

    @wedsonaf
    the @dakr changed this function in 2024/10/04 (git show 8373147ce4961)

    the diff

    -    pub fn into_node(mut self, key: K, value: V) -> RBTreeNode<K, V> {
    -        self.node.write(Node {
    -            key,
    -            value,
    -            links: bindings::rb_node::default(),
    -        });
    -        // SAFETY: We just wrote to it.
    -        let node = unsafe { self.node.assume_init() };
    +    pub fn into_node(self, key: K, value: V) -> RBTreeNode<K, V> {
    +        let node = KBox::write(
    +            self.node,
    +            Node {
    +                key,
    +                value,
    +                links: bindings::rb_node::default(),
    +            },
    +        );

    He was removed the self.node.assume_init() ..

    If you try pass the result of KBox::write(...) for KBox::assume_init(...) the compiler return

        --> rust/kernel/rbtree.rs:1074:27
         |
    1074 |         KBox::assume_init(node);
         |         ----------------- ^^^^ expected `Box<MaybeUninit<_>, Kmalloc>`, found `Box<Node<K, V>, Kmalloc>`
         |         |
         |         arguments to this function are incorrect
    

    Maybe this is already resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    • libRelated to the `rust/` library.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions