From 063b281c396babc053d8a1d8dd5a79a8d17808a3 Mon Sep 17 00:00:00 2001 From: Boshen Date: Sat, 13 Apr 2024 12:31:40 +0800 Subject: [PATCH] feat(allocator): make `Box`'s PhantomData own the passed in `T` (#2952) --- .github/workflows/miri.yml | 2 ++ crates/oxc_allocator/src/arena.rs | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/miri.yml b/.github/workflows/miri.yml index be7fc679c..bcbc52dc5 100644 --- a/.github/workflows/miri.yml +++ b/.github/workflows/miri.yml @@ -6,12 +6,14 @@ on: types: [opened, synchronize] paths: - 'crates/oxc_parser/**' + - 'crates/oxc_allocator/**' - '.github/workflows/miri.yml' push: branches: - main paths: - 'crates/oxc_parser/**' + - 'crates/oxc_allocator/**' - '.github/workflows/miri.yml' concurrency: diff --git a/crates/oxc_allocator/src/arena.rs b/crates/oxc_allocator/src/arena.rs index 0dec1cdaf..ffd5a089b 100644 --- a/crates/oxc_allocator/src/arena.rs +++ b/crates/oxc_allocator/src/arena.rs @@ -20,7 +20,7 @@ use crate::Allocator; /// A Box without Drop. /// This is used for over coming self-referential structs. /// It is a memory leak if the boxed value has a `Drop` implementation. -pub struct Box<'alloc, T: ?Sized>(NonNull, PhantomData<&'alloc T>); +pub struct Box<'alloc, T: ?Sized>(NonNull, PhantomData<(&'alloc (), T)>); impl<'alloc, T> Box<'alloc, T> { #[allow(unsafe_code)]