oxc/crates/oxc_semantic/src
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
..
checker refactor: rename CompactString to CompactStr (#2619) 2024-03-06 12:24:23 +08:00
class Make ast types covariant over the allocator lifetime. (#2943) 2024-04-12 18:12:18 +08:00
jsdoc refactor(semantic/jsdoc): Rework JSDoc struct for better Span handling (#2917) 2024-04-10 14:32:51 +08:00
module_record fix(linter/import): ignore export declaration in no-duplicates (#2863) 2024-03-30 12:57:43 +08:00
binder.rs fix(semantic): flag function expressions with SymbolFlags::Function (#2891) 2024-04-03 10:42:11 +08:00
builder.rs fix(semantic): symbols inside functions and classes incorrectly flagged as exported (#2896) 2024-04-05 23:01:27 +08:00
control_flow.rs refactor: rename CompactString to CompactStr (#2619) 2024-03-06 12:24:23 +08:00
diagnostics.rs refactor: rename CompactString to CompactStr (#2619) 2024-03-06 12:24:23 +08:00
label.rs refactor(semantic): checking label in ContinueStatement based on LabelBuilder (#2202) 2024-01-29 18:24:42 +08:00
lib.rs feat(linter): Implement jsdoc/check-access (#2642) 2024-04-04 22:36:39 +08:00
node.rs feat(semantic): track cfg index per ast node (#2210) 2024-02-01 13:27:20 +08:00
pg.rs fix(oxc_semantic): proper traversal of try statements (#2250) 2024-02-01 20:46:38 +08:00
reference.rs chore: silence erroneous RA warnings for Tsify (#2731) 2024-03-15 12:42:12 +00:00
scope.rs refactor: rename CompactString to CompactStr (#2619) 2024-03-06 12:24:23 +08:00
symbol.rs chore: silence erroneous RA warnings for Tsify (#2731) 2024-03-15 12:42:12 +00:00