Skip to content

Commit 6c0d31b

Browse files
authored
refactor(linter): remove useless const declaration (#7430)
Remove uesless const declaration, since they need to access flags, so they should never be evaluated in compiling time. Or does this keyword have some other functions I missed?
1 parent 9522d52 commit 6c0d31b

2 files changed

Lines changed: 7 additions & 8 deletions

File tree

crates/oxc_linter/src/rules/eslint/no_unused_vars/symbol.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ impl<'s, 'a> Symbol<'s, 'a> {
4545
}
4646

4747
#[inline]
48-
pub const fn flags(&self) -> SymbolFlags {
48+
pub fn flags(&self) -> SymbolFlags {
4949
self.flags
5050
}
5151

crates/oxc_linter/src/rules/eslint/no_unused_vars/usage.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ impl<'s, 'a> Symbol<'s, 'a> {
2323
/// 2. Catch variables are always parameter-like and will therefore never have
2424
/// a function declaration.
2525
#[inline]
26-
const fn is_maybe_callable(&self) -> bool {
26+
fn is_maybe_callable(&self) -> bool {
2727
// NOTE: imports are technically callable, but that call will never
2828
// occur within its own declaration since it's declared in another
2929
// module.
@@ -47,8 +47,8 @@ impl<'s, 'a> Symbol<'s, 'a> {
4747
/// eslint's original rule requires it. Const reassignments are not a syntax
4848
/// error in JavaScript, only TypeScript.
4949
#[inline]
50-
const fn is_possibly_reassignable(&self) -> bool {
51-
self.flags().intersects(SymbolFlags::Variable)
50+
fn is_possibly_reassignable(&self) -> bool {
51+
self.flags().is_variable()
5252
}
5353

5454
/// Check if this [`Symbol`] is definitely reassignable.
@@ -65,10 +65,9 @@ impl<'s, 'a> Symbol<'s, 'a> {
6565
/// - `var` and `let` variable declarations
6666
/// - function parameters
6767
#[inline]
68-
const fn is_definitely_reassignable_variable(&self) -> bool {
68+
fn is_definitely_reassignable_variable(&self) -> bool {
6969
let f = self.flags();
70-
f.intersects(SymbolFlags::Variable)
71-
&& !f.contains(SymbolFlags::ConstVariable.union(SymbolFlags::Function))
70+
f.is_variable() && !f.contains(SymbolFlags::ConstVariable.union(SymbolFlags::Function))
7271
}
7372

7473
/// Checks if this [`Symbol`] could be used as a type reference within its
@@ -77,7 +76,7 @@ impl<'s, 'a> Symbol<'s, 'a> {
7776
/// This does _not_ imply this symbol is a type (negative cases include type
7877
/// imports, type parameters, etc).
7978
#[inline]
80-
const fn could_have_type_reference_within_own_decl(&self) -> bool {
79+
fn could_have_type_reference_within_own_decl(&self) -> bool {
8180
#[rustfmt::skip]
8281
const TYPE_DECLS: SymbolFlags = SymbolFlags::TypeAlias
8382
.union(SymbolFlags::Interface)

0 commit comments

Comments
 (0)