oxc/crates/oxc_semantic
branchseer f159f60084
Make ast types covariant over the allocator lifetime. (#2943)
## Why

Due to the usage of `&'alloc mut T` in `oxc_allocator::Box`, and
`bumpalo::collections::Vec` in `oxc_allocator::Vec`, ast types are
currently invariant over their allocator lifetime `'a`. This prevents
`ouroboros` from generating `borrow_*` on ast type fields, leading to
the unfriendly `with_*` api:
c250b288ef/crates/oxc_parser/examples/multi-thread.rs (L82-L84)

## How

- For `oxc_allocator::Vec`, switch to `allocator_api2::vec::Vec`, which
has a covariant relationship with the allocator lifetime.
- For `oxc_allocator::Box`, use `std::ptr::NonNull` which is
specifically designed to be covariant. I don't use
`allocator_api2::boxed::Box` because it holds the allocator for
dropping, so the size is bigger.

## Downside

Now that `oxc_allocator::Box` uses the unsafe `NonNull`. It has to be a
private field to be safe. This make it impossible to do `Box(....)`
pattern matching.
2024-04-12 18:12:18 +08:00
..
examples refactor: remove panic! from examples (#2454) 2024-02-20 16:18:39 +08:00
src Make ast types covariant over the allocator lifetime. (#2943) 2024-04-12 18:12:18 +08:00
tests fix(semantic): symbols inside functions and classes incorrectly flagged as exported (#2896) 2024-04-05 23:01:27 +08:00
Cargo.toml Release crates v0.12.3 2024-04-11 16:18:17 +08:00
CHANGELOG.md Release crates v0.12.3 2024-04-11 16:18:17 +08:00