From 770652327ddf917bc80159502d7a771b2709b1aa Mon Sep 17 00:00:00 2001 From: overlookmotel <557937+overlookmotel@users.noreply.github.com> Date: Mon, 19 Aug 2024 11:53:01 +0000 Subject: [PATCH] refactor(span): clarify `Atom` conversion methods lifetimes (#4978) Rename lifetimes on `FromIn` impls for `Atom`s to make it clear where the lifetime of the `Atom` comes from the allocator's lifetime. --- crates/oxc_span/src/atom.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/crates/oxc_span/src/atom.rs b/crates/oxc_span/src/atom.rs index 1176bae6dd610..8e2eae50edeea 100644 --- a/crates/oxc_span/src/atom.rs +++ b/crates/oxc_span/src/atom.rs @@ -67,32 +67,32 @@ impl<'old_alloc, 'new_alloc> CloneIn<'new_alloc> for Atom<'old_alloc> { } } -impl<'a, 'b> FromIn<'a, &'b Atom<'a>> for Atom<'a> { - fn from_in(s: &'b Atom<'a>, _: &'a Allocator) -> Self { +impl<'alloc> FromIn<'alloc, &Atom<'alloc>> for Atom<'alloc> { + fn from_in(s: &Atom<'alloc>, _: &'alloc Allocator) -> Self { Self::from(s.0) } } -impl<'a, 'b> FromIn<'a, &'b str> for Atom<'a> { - fn from_in(s: &'b str, allocator: &'a Allocator) -> Self { +impl<'alloc> FromIn<'alloc, &str> for Atom<'alloc> { + fn from_in(s: &str, allocator: &'alloc Allocator) -> Self { Self::from(oxc_allocator::String::from_str_in(s, allocator).into_bump_str()) } } -impl<'a> FromIn<'a, String> for Atom<'a> { - fn from_in(s: String, allocator: &'a Allocator) -> Self { +impl<'alloc> FromIn<'alloc, String> for Atom<'alloc> { + fn from_in(s: String, allocator: &'alloc Allocator) -> Self { Self::from_in(s.as_str(), allocator) } } -impl<'a> FromIn<'a, &String> for Atom<'a> { - fn from_in(s: &String, allocator: &'a Allocator) -> Self { +impl<'alloc> FromIn<'alloc, &String> for Atom<'alloc> { + fn from_in(s: &String, allocator: &'alloc Allocator) -> Self { Self::from_in(s.as_str(), allocator) } } -impl<'a, 'b> FromIn<'a, Cow<'b, str>> for Atom<'a> { - fn from_in(s: Cow<'b, str>, allocator: &'a Allocator) -> Self { +impl<'alloc> FromIn<'alloc, Cow<'_, str>> for Atom<'alloc> { + fn from_in(s: Cow<'_, str>, allocator: &'alloc Allocator) -> Self { Self::from_in(&*s, allocator) } }