oxc-project / oxc-project/backlog
Give `Address` a niche
Nobody has claimed this yet.
- Dominant language
- No language data
- Stars
- 7
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
Address is the memory address of an AST node. Currently it's a wrapper around a usize.
But an AST node in the arena cannot have a null address. Therefore we could make Address:
#[repr(transparent)]
pub struct Address(NonZeroUsize);
This would make Option<Address> 8 bytes (currently it's 16).
This is trivial to do for impl<T> GetAddress for Box<'_, T>.
But would need to change the signature of Address:from_ptr to take a NonNull<T> instead of *const T. This would break all cases where we pass a &T to Address::from_ptr, because &T does not auto-deref to NonNull<T> the way it does to *const T.
That might well not be a bad thing - Address:from_ptr is not recommended usage, so making you jump through more hoops to use it could be helpful. And it doesn't require unsafe code from the caller - Address::from_ptr(&x) -> Address::from_ptr(NonNull::from(&x)).
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the Address definition, its from_ptr method, the GetAddress implementation for Box, and call sites that pass references. Check how AST nodes are allocated in the arena and inspect existing tests or size assertions if present. Done means Address uses NonZeroUsize, Option
is 8 bytes, and all affected call sites compile with the updated from_ptr signature.Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Refactor
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100