oxc/crates
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
..
oxc Release crates v0.12.3 2024-04-11 16:18:17 +08:00
oxc_allocator Make ast types covariant over the allocator lifetime. (#2943) 2024-04-12 18:12:18 +08:00
oxc_ast Make ast types covariant over the allocator lifetime. (#2943) 2024-04-12 18:12:18 +08:00
oxc_cli feat(linter): Add --jsdoc-plugin flag (#2935) 2024-04-12 10:39:12 +08:00
oxc_codegen Make ast types covariant over the allocator lifetime. (#2943) 2024-04-12 18:12:18 +08:00
oxc_diagnostics Release crates v0.12.3 2024-04-11 16:18:17 +08:00
oxc_index Release crates v0.12.3 2024-04-11 16:18:17 +08:00
oxc_js_regex refactor: rename CompactString to CompactStr (#2619) 2024-03-06 12:24:23 +08:00
oxc_language_server chore: apply cargo autoinherit (#2826) 2024-03-26 23:57:50 +08:00
oxc_linter Make ast types covariant over the allocator lifetime. (#2943) 2024-04-12 18:12:18 +08:00
oxc_macros chore: bump syn to v2 (#2888) 2024-04-02 20:57:09 +08:00
oxc_minifier Make ast types covariant over the allocator lifetime. (#2943) 2024-04-12 18:12:18 +08:00
oxc_module_lexer refactor(ast): add walk_mut functions (#2776) 2024-03-25 20:40:13 +03:30
oxc_parser Make ast types covariant over the allocator lifetime. (#2943) 2024-04-12 18:12:18 +08:00
oxc_prettier Make ast types covariant over the allocator lifetime. (#2943) 2024-04-12 18:12:18 +08:00
oxc_semantic Make ast types covariant over the allocator lifetime. (#2943) 2024-04-12 18:12:18 +08:00
oxc_sourcemap Release crates v0.12.3 2024-04-11 16:18:17 +08:00
oxc_span Release crates v0.12.3 2024-04-11 16:18:17 +08:00
oxc_syntax Release crates v0.12.3 2024-04-11 16:18:17 +08:00
oxc_transformer feat(transformer): implement react-jsx-self (#2946) 2024-04-12 18:08:36 +08:00
oxc_wasm feat(transformer): add filename (#2941) 2024-04-11 18:43:51 +08:00