Skip to content

Commit

Permalink
refactor(linter): inline Rule trait default methods (#5619)
Browse files Browse the repository at this point in the history
Hopefully compiler is already inlining these trivial/empty methods, but mark them `#[inline]` to make sure.
  • Loading branch information
overlookmotel committed Sep 9, 2024
1 parent a0370bf commit 89bdf55
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions crates/oxc_linter/src/rule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,17 @@ pub trait Rule: Sized + Default + fmt::Debug {

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

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

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

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

0 comments on commit 89bdf55

Please sign in to comment.