Skip to content

semantic: Remove Option from parent_* methods #11946

@camchenry

Description

@camchenry

Originally suggested by @overlookmotel. Currently, all of the methods relating to getting a node's parent ID/kind/node return Option<&AstNode>. However, we know that all AST nodes should have a parent, with the exception of Program. In this case, we could have Program be self-referential: it will return its parent ID as itself, and then we can remove Option from the return type of all methods fetching parent data. This would remove a lot of boilerplate code in the linter and elsewhere. Could potentially improve performance as well by removing lots of unnecessary branches which means fewer instructions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions