diff --git a/crates/oxc_language_server/src/linter.rs b/crates/oxc_language_server/src/linter.rs index 2e224855d27ac..9dbfb3e8d34a8 100644 --- a/crates/oxc_language_server/src/linter.rs +++ b/crates/oxc_language_server/src/linter.rs @@ -305,7 +305,7 @@ impl IsolatedLintHandler { let lint_ctx = LintContext::new( path.to_path_buf().into_boxed_path(), - &Rc::new(semantic_ret.semantic), + Rc::new(semantic_ret.semantic), ); let result = linter.run(lint_ctx); diff --git a/crates/oxc_linter/src/context.rs b/crates/oxc_linter/src/context.rs index 5c53c13a33859..babf3237a9d96 100644 --- a/crates/oxc_linter/src/context.rs +++ b/crates/oxc_linter/src/context.rs @@ -34,11 +34,11 @@ pub struct LintContext<'a> { } impl<'a> LintContext<'a> { - pub fn new(file_path: Box, semantic: &Rc>) -> Self { + pub fn new(file_path: Box, semantic: Rc>) -> Self { let disable_directives = DisableDirectivesBuilder::new(semantic.source_text(), semantic.trivias()).build(); Self { - semantic: Rc::clone(semantic), + semantic, diagnostics: RefCell::new(vec![]), disable_directives: Rc::new(disable_directives), fix: false, diff --git a/crates/oxc_linter/src/service.rs b/crates/oxc_linter/src/service.rs index b98ae4f89d9ab..c5e4262989b1e 100644 --- a/crates/oxc_linter/src/service.rs +++ b/crates/oxc_linter/src/service.rs @@ -351,7 +351,7 @@ impl Runtime { }; let lint_ctx = - LintContext::new(path.to_path_buf().into_boxed_path(), &Rc::new(semantic_ret.semantic)); + LintContext::new(path.to_path_buf().into_boxed_path(), Rc::new(semantic_ret.semantic)); self.linter.run(lint_ctx) } diff --git a/crates/oxc_linter/src/utils/jest.rs b/crates/oxc_linter/src/utils/jest.rs index 29f8f781b0121..ef0ad8a44dd8b 100644 --- a/crates/oxc_linter/src/utils/jest.rs +++ b/crates/oxc_linter/src/utils/jest.rs @@ -317,15 +317,15 @@ mod test { let semantic_ret = Rc::new(semantic_ret); let path = Path::new("foo.js"); - let ctx = LintContext::new(Box::from(path), &semantic_ret); + let ctx = LintContext::new(Box::from(path), Rc::clone(&semantic_ret)); assert!(!super::is_jest_file(&ctx)); let path = Path::new("foo.test.js"); - let ctx = LintContext::new(Box::from(path), &semantic_ret); + let ctx = LintContext::new(Box::from(path), Rc::clone(&semantic_ret)); assert!(super::is_jest_file(&ctx)); let path = Path::new("__tests__/foo/test.spec.js"); - let ctx = LintContext::new(Box::from(path), &semantic_ret); + let ctx = LintContext::new(Box::from(path), semantic_ret); assert!(super::is_jest_file(&ctx)); } } diff --git a/crates/oxc_wasm/src/lib.rs b/crates/oxc_wasm/src/lib.rs index d829cd63456d6..4ca3722973920 100644 --- a/crates/oxc_wasm/src/lib.rs +++ b/crates/oxc_wasm/src/lib.rs @@ -192,7 +192,7 @@ impl Oxc { let semantic = Rc::new(semantic_ret.semantic); // Only lint if there are not syntax errors if run_options.lint() && self.diagnostics.borrow().is_empty() { - let lint_ctx = LintContext::new(path.clone().into_boxed_path(), &semantic); + let lint_ctx = LintContext::new(path.clone().into_boxed_path(), Rc::clone(&semantic)); let linter_ret = Linter::default().run(lint_ctx); let diagnostics = linter_ret.into_iter().map(|e| Error::from(e.error)).collect(); self.save_diagnostics(diagnostics); diff --git a/tasks/benchmark/benches/linter.rs b/tasks/benchmark/benches/linter.rs index e83eeb2c83f3a..6cee90cd04c89 100644 --- a/tasks/benchmark/benches/linter.rs +++ b/tasks/benchmark/benches/linter.rs @@ -47,7 +47,10 @@ fn bench_linter(criterion: &mut Criterion) { let linter = Linter::from_options(lint_options).unwrap(); let semantic = Rc::new(semantic_ret.semantic); b.iter(|| { - linter.run(LintContext::new(PathBuf::from("").into_boxed_path(), &semantic)) + linter.run(LintContext::new( + PathBuf::from("").into_boxed_path(), + Rc::clone(&semantic), + )) }); }, );