From 26d3a39f2b3aaef79daf8c194b063e43a93afec0 Mon Sep 17 00:00:00 2001 From: overlookmotel <557937+overlookmotel@users.noreply.github.com> Date: Wed, 16 Jul 2025 23:03:18 +0000 Subject: [PATCH] refactor(linter): remove `ModuleContentOwner` abstraction (#12331) Pure refactor. Remove `ModuleContentOwner` abstraction. It's just a wrapper around `AllocatorGuard` and adds no value in itself, so remove it and use `AllocatorGuard` directly. --- crates/oxc_linter/src/service/runtime.rs | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/crates/oxc_linter/src/service/runtime.rs b/crates/oxc_linter/src/service/runtime.rs index 18cfecc0c73a3..519e30f7778c2 100644 --- a/crates/oxc_linter/src/service/runtime.rs +++ b/crates/oxc_linter/src/service/runtime.rs @@ -88,7 +88,7 @@ struct ResolvedModuleRecord { self_cell! { struct ModuleContent<'alloc_pool> { - owner: ModuleContentOwner<'alloc_pool>, + owner: AllocatorGuard<'alloc_pool>, #[not_covariant] dependent: ModuleContentDependent, } @@ -101,10 +101,6 @@ struct ModuleContentDependent<'a> { // Safety: dependent borrows from owner. They're safe to be sent together. unsafe impl Send for ModuleContent<'_> {} -struct ModuleContentOwner<'alloc_pool> { - allocator: AllocatorGuard<'alloc_pool>, -} - /// source text and semantic for each source section. They are in the same order as `ProcessedModule.section_module_records` type SectionContents<'a> = SmallVec<[SectionContent<'a>; 1]>; struct SectionContent<'a> { @@ -812,9 +808,8 @@ impl Runtime { if self.paths.contains(path) { let allocator = self.allocator_pool.get(); - let build = ModuleContent::try_new(ModuleContentOwner { allocator }, |owner| { - let Some(stt) = - self.get_source_type_and_text(Path::new(path), ext, &owner.allocator) + let build = ModuleContent::try_new(allocator, |allocator| { + let Some(stt) = self.get_source_type_and_text(Path::new(path), ext, allocator) else { return Err(()); }; @@ -834,7 +829,7 @@ impl Runtime { check_syntax_errors, source_type, source_text, - &owner.allocator, + allocator, Some(&mut section_contents), );