Skip to content

Commit 491c401

Browse files
committed
refactor(linter): remove #[must_use] from LintService::with_* methods (#12560)
Pure refactor. Remove `#[must_use]` from `LintService::with_paths` and `LintService::with_file_system`. I assume these are left over from a past time when these methods took and returned `self`. Also, make these same methods on `Runtime` return `&mut Self` not `&Self`. We don't use the return value of these methods, but presumably they're meant to support chaining.
1 parent d44b0ac commit 491c401

File tree

4 files changed

+5
-7
lines changed

4 files changed

+5
-7
lines changed

apps/oxlint/src/lint.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,14 +321,14 @@ impl LintRunner {
321321
// Spawn linting in another thread so diagnostics can be printed immediately from diagnostic_service.run.
322322
rayon::spawn(move || {
323323
let mut lint_service = LintService::new(linter, allocator_pool, options);
324-
let _ = lint_service.with_paths(paths);
324+
lint_service.with_paths(paths);
325325

326326
// Use `RawTransferFileSystem` if `oxlint2` feature is enabled.
327327
// This reads the source text into start of allocator, instead of the end.
328328
#[cfg(all(feature = "oxlint2", not(feature = "disable_oxlint2")))]
329329
{
330330
use crate::raw_fs::RawTransferFileSystem;
331-
let _ = lint_service.with_file_system(Box::new(RawTransferFileSystem));
331+
lint_service.with_file_system(Box::new(RawTransferFileSystem));
332332
}
333333

334334
lint_service.run(&tx_error);

crates/oxc_linter/src/service/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ impl LintService {
7575
Self { runtime }
7676
}
7777

78-
#[must_use]
7978
pub fn with_file_system(
8079
&mut self,
8180
file_system: Box<dyn RuntimeFileSystem + Sync + Send>,
@@ -84,7 +83,6 @@ impl LintService {
8483
self
8584
}
8685

87-
#[must_use]
8886
pub fn with_paths(&mut self, paths: Vec<Arc<OsStr>>) -> &mut Self {
8987
self.runtime.with_paths(paths);
9088
self

crates/oxc_linter/src/service/runtime.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,12 +195,12 @@ impl Runtime {
195195
pub fn with_file_system(
196196
&mut self,
197197
file_system: Box<dyn RuntimeFileSystem + Sync + Send>,
198-
) -> &Self {
198+
) -> &mut Self {
199199
self.file_system = file_system;
200200
self
201201
}
202202

203-
pub fn with_paths(&mut self, paths: Vec<Arc<OsStr>>) -> &Self {
203+
pub fn with_paths(&mut self, paths: Vec<Arc<OsStr>>) -> &mut Self {
204204
self.paths = paths.into_iter().collect();
205205
self
206206
}

crates/oxc_linter/src/tester.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ impl Tester {
545545
let paths = vec![Arc::<OsStr>::from(path_to_lint.as_os_str())];
546546
let options = LintServiceOptions::new(cwd).with_cross_module(self.plugins.has_import());
547547
let mut lint_service = LintService::new(linter, AllocatorPool::default(), options);
548-
let _ = lint_service
548+
lint_service
549549
.with_file_system(Box::new(TesterFileSystem::new(
550550
path_to_lint,
551551
source_text.to_string(),

0 commit comments

Comments
 (0)