Skip to content

LinkedList implementation violates aliasing rules #34417

Closed
@Amanieu

Description

@Amanieu

The nodes in LinkedList look like this:

struct Node<T> {
    next: Option<Box<Node<T>>>,
    prev: Option<Shared<Node<T>>>,
    value: T,
}

Box uses Unique, which requires that it "the referent of the pointer should not be modified without a unique path to the Unique reference". This effectively means that Unique doesn't allow aliases, but this rule violated by the prev pointer which point to the same node as a Unique.

While Rust currently doesn't give noalias semantics to Unique, this is planned in the future and will silently break LinkedList.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P-mediumMedium priorityT-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions