Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions crates/oxc_allocator/src/arena.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ impl<'alloc, T> Box<'alloc, T> {
pub fn new_in(x: T, alloc: &Allocator) -> Self {
Self(alloc.alloc(x).into(), PhantomData)
}

/// Create a fake `Box` with a dangling pointer.
/// # SAFETY
/// Safe to create, but must never be dereferenced, as does not point to a valid `T`.
/// Only purpose is for mocking types without allocating for const assertions.
#[allow(unsafe_code, clippy::missing_safety_doc)]
pub const unsafe fn dangling() -> Self {
Self(NonNull::dangling(), PhantomData)
}
}

impl<'alloc, T: ?Sized> ops::Deref for Box<'alloc, T> {
Expand Down
Loading