Skip to content

Commit 89bdf55

Browse files
committed
refactor(linter): inline Rule trait default methods (#5619)
Hopefully compiler is already inlining these trivial/empty methods, but mark them `#[inline]` to make sure.
1 parent a0370bf commit 89bdf55

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

crates/oxc_linter/src/rule.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,17 @@ pub trait Rule: Sized + Default + fmt::Debug {
1717

1818
/// Visit each AST Node
1919
#[expect(unused_variables)]
20+
#[inline]
2021
fn run<'a>(&self, node: &AstNode<'a>, ctx: &LintContext<'a>) {}
2122

2223
/// Visit each symbol
2324
#[expect(unused_variables)]
25+
#[inline]
2426
fn run_on_symbol(&self, symbol_id: SymbolId, ctx: &LintContext<'_>) {}
2527

2628
/// Run only once. Useful for inspecting scopes and trivias etc.
2729
#[expect(unused_variables)]
30+
#[inline]
2831
fn run_once(&self, ctx: &LintContext) {}
2932

3033
/// Check if a rule should be run at all.
@@ -35,6 +38,7 @@ pub trait Rule: Sized + Default + fmt::Debug {
3538
///
3639
/// [`linter`]: crate::Linter
3740
#[expect(unused_variables)]
41+
#[inline]
3842
fn should_run(&self, ctx: &LintContext) -> bool {
3943
true
4044
}

0 commit comments

Comments
 (0)