From 452c879ed53dcaf0dfca42ace53d5cb3be6756b9 Mon Sep 17 00:00:00 2001 From: rzvxa Date: Wed, 7 Aug 2024 17:25:29 +0330 Subject: [PATCH] fix: cleanup. --- crates/oxc_allocator/src/clone_in.rs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/crates/oxc_allocator/src/clone_in.rs b/crates/oxc_allocator/src/clone_in.rs index 4252af25c6ea04..62ad41664fb36b 100644 --- a/crates/oxc_allocator/src/clone_in.rs +++ b/crates/oxc_allocator/src/clone_in.rs @@ -1,3 +1,5 @@ +use std::cell::Cell; + use crate::{Allocator, Box, Vec}; /// A trait to explicitly clone an object into an arena allocator. @@ -23,12 +25,12 @@ pub trait CloneIn<'new_alloc>: Sized { fn clone_in(&self, alloc: &'new_alloc Allocator) -> Self::Cloned; } -impl<'a, T, C> CloneIn<'a> for Option +impl<'alloc, T, C> CloneIn<'alloc> for Option where - T: CloneIn<'a, Cloned = C>, + T: CloneIn<'alloc, Cloned = C>, { type Cloned = Option; - fn clone_in(&self, alloc: &'a Allocator) -> Self::Cloned { + fn clone_in(&self, alloc: &'alloc Allocator) -> Self::Cloned { self.as_ref().map(|it| it.clone_in(alloc)) } } @@ -53,9 +55,9 @@ where } } -impl<'a, T: Copy> CloneIn<'a> for std::cell::Cell { - type Cloned = std::cell::Cell; - fn clone_in(&self, _: &'a Allocator) -> Self::Cloned { +impl<'alloc, T: Copy> CloneIn<'alloc> for Cell { + type Cloned = Cell; + fn clone_in(&self, _: &'alloc Allocator) -> Self::Cloned { Self::Cloned::new(self.get()) } } @@ -70,10 +72,10 @@ impl<'old_alloc, 'new_alloc> CloneIn<'new_alloc> for &'old_alloc str { macro_rules! impl_clone_in { ($($t:ty)*) => { $( - impl<'a> CloneIn<'a> for $t { + impl<'alloc> CloneIn<'alloc> for $t { type Cloned = Self; #[inline(always)] - fn clone_in(&self, _: &'a Allocator) -> Self { + fn clone_in(&self, _: &'alloc Allocator) -> Self { *self } }