Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFC007] Clean the AST alloc interface #2111

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Commits on Nov 27, 2024

  1. Clean the AST alloc interface

    A previous PR introduced generic `alloc` and `alloc_iter` methods,
    instead of needing a myriad of `xxx_move` functions for each and every
    AST component type. However, this poses a risk of memory leak because
    this method allocates in the generic bumpalo arena, which doesn't run
    destructors.
    
    This commit makes this approach safer by using a marker trait which
    forbids some AST components from being allocated through this method,
    when they need to be dropped. Anecdotally, `alloc_iter` is renamed to
    `alloc_many` and a specialized version `alloc_singleton` is added to
    eliminate a lot of `alloc.alloc_many(iter::once(x))`.
    
    In a second time, all the legacy `xxx_move` variants or the like are
    removed, and replaced with `alloc` and `alloc_many` whenever possible,
    making the interface of `AstAlloc` quite smaller.
    yannham committed Nov 27, 2024
    Configuration menu
    Copy the full SHA
    64302a5 View commit details
    Browse the repository at this point in the history