Skip to content

Should empty nodes be allowed? #10

@matklad

Description

@matklad
Member

In principle, it is possible to have nodes of length zero: this would be an internal node without children.

However such nodes are annoying to work with. For example, with empty nodes there maybe arbitrary number of nodes at a given offset (as opposed to at most two for non-empty nodes). So it seems a great idea to forbid this node.

That means that care must be taken to parse stuff like use foo::92; without empty nodes: we know that there should be a path segment after ::, but we shouldn't create a node for it unconditionally.

A funny edge case here is an empty file: We'll have to create a file node for it, and it will be empty.

Activity

matklad

matklad commented on Dec 29, 2018

@matklad
MemberAuthor

For the time being, only the file node can be empty, and this works out OK

added a commit that references this issue on Apr 3, 2022
eacd72d
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @matklad

        Issue actions

          Should empty nodes be allowed? · Issue #10 · rust-lang/rust-analyzer