diff --git a/crates/oxc_allocator/src/arena.rs b/crates/oxc_allocator/src/arena.rs index 6fd3501cd..c8adf7eac 100644 --- a/crates/oxc_allocator/src/arena.rs +++ b/crates/oxc_allocator/src/arena.rs @@ -145,11 +145,12 @@ impl<'alloc, T> ops::Index for &'alloc Vec<'alloc, T> { } } -impl<'alloc, T> ops::IndexMut for Vec<'alloc, T> { - fn index_mut(&mut self, index: usize) -> &mut Self::Output { - self.0.index_mut(index) - } -} +// Unused right now. +// impl<'alloc, T> ops::IndexMut for Vec<'alloc, T> { +// fn index_mut(&mut self, index: usize) -> &mut Self::Output { +// self.0.index_mut(index) +// } +// } impl<'alloc, T> Serialize for Vec<'alloc, T> where diff --git a/crates/oxc_macros/src/declare_oxc_lint.rs b/crates/oxc_macros/src/declare_oxc_lint.rs index 5aec3a872..16ee835bd 100644 --- a/crates/oxc_macros/src/declare_oxc_lint.rs +++ b/crates/oxc_macros/src/declare_oxc_lint.rs @@ -6,20 +6,6 @@ use syn::{ Attribute, Error, Ident, Lit, LitStr, Meta, Result, Token, }; -fn parse_attr(path: [&'static str; LEN], attr: &Attribute) -> Option { - if let Meta::NameValue(name_value) = attr.parse_meta().ok()? { - let path_idents = name_value.path.segments.iter().map(|segment| &segment.ident); - - if itertools::equal(path_idents, path) { - if let Lit::Str(lit) = name_value.lit { - return Some(lit); - } - } - } - - None -} - pub struct LintRuleMeta { name: Ident, category: Ident, @@ -90,3 +76,16 @@ pub fn declare_oxc_lint(metadata: LintRuleMeta) -> TokenStream { output } + +fn parse_attr(path: [&'static str; LEN], attr: &Attribute) -> Option { + if let Meta::NameValue(name_value) = attr.parse_meta().ok()? { + let path_idents = name_value.path.segments.iter().map(|segment| &segment.ident); + + if itertools::equal(path_idents, path) { + if let Lit::Str(lit) = name_value.lit { + return Some(lit); + } + } + } + unreachable!() +} diff --git a/crates/oxc_parser/src/js/function.rs b/crates/oxc_parser/src/js/function.rs index 0d3247dd1..48933f2d8 100644 --- a/crates/oxc_parser/src/js/function.rs +++ b/crates/oxc_parser/src/js/function.rs @@ -16,14 +16,14 @@ type ArrowFunctionHead<'a> = ( Span, ); -#[derive(Debug, Copy, Clone)] +#[derive(Debug, Clone, Copy)] pub enum IsParenthesizedArrowFunction { True, False, Maybe, } -#[derive(PartialEq, Eq, Debug, Copy, Clone)] +#[derive(Debug, Clone, Copy, Eq, PartialEq)] pub enum FunctionKind { Declaration { single_statement: bool }, Expression, diff --git a/crates/oxc_parser/src/lexer/token.rs b/crates/oxc_parser/src/lexer/token.rs index 230f57df2..f986e538a 100644 --- a/crates/oxc_parser/src/lexer/token.rs +++ b/crates/oxc_parser/src/lexer/token.rs @@ -5,7 +5,7 @@ use oxc_span::Span; use super::kind::Kind; -#[derive(Debug, Clone, PartialEq, Default)] +#[derive(Debug, Clone, Default)] pub struct Token<'a> { /// Token Kind pub kind: Kind, @@ -38,7 +38,7 @@ impl<'a> Token<'a> { } } -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone)] pub enum TokenValue<'a> { None, Number(f64), @@ -47,7 +47,7 @@ pub enum TokenValue<'a> { RegExp(RegExp<'a>), } -#[derive(Debug, Clone, PartialEq, Eq)] +#[derive(Debug, Clone)] pub struct RegExp<'a> { pub pattern: &'a str, pub flags: RegExpFlags, @@ -63,21 +63,21 @@ impl<'a> TokenValue<'a> { pub fn as_number(&self) -> f64 { match self { Self::Number(s) => *s, - _ => panic!("expected number!"), + _ => unreachable!("expected number!"), } } pub fn as_bigint(&self) -> num_bigint::BigInt { match self { Self::BigInt(s) => s.clone(), - _ => panic!("expected bigint!"), + _ => unreachable!("expected bigint!"), } } pub fn as_regex(&self) -> &RegExp<'a> { match self { Self::RegExp(regex) => regex, - _ => panic!("expected regex!"), + _ => unreachable!("expected regex!"), } } diff --git a/crates/oxc_parser/src/ts/statement.rs b/crates/oxc_parser/src/ts/statement.rs index 74d7a0131..a182e5d9c 100644 --- a/crates/oxc_parser/src/ts/statement.rs +++ b/crates/oxc_parser/src/ts/statement.rs @@ -30,7 +30,7 @@ impl<'a> Parser<'a> { span: Span, modifiers: Modifiers<'a>, ) -> Result> { - self.expect(Kind::Enum)?; + self.bump_any(); // bump `enum` let id = self.parse_binding_identifier()?; let members = TSEnumMemberList::parse(self)?.members; diff --git a/crates/oxc_resolver/src/cache.rs b/crates/oxc_resolver/src/cache.rs index b1b4a0fcb..04cd35676 100644 --- a/crates/oxc_resolver/src/cache.rs +++ b/crates/oxc_resolver/src/cache.rs @@ -27,7 +27,7 @@ struct IdentityHasher(u64); impl Hasher for IdentityHasher { fn write(&mut self, _: &[u8]) { - panic!("Invalid use of IdentityHasher") + unreachable!("Invalid use of IdentityHasher") } fn write_u64(&mut self, n: u64) { self.0 = n; diff --git a/crates/oxc_syntax/src/scope.rs b/crates/oxc_syntax/src/scope.rs index 8fec0a106..1c755110f 100644 --- a/crates/oxc_syntax/src/scope.rs +++ b/crates/oxc_syntax/src/scope.rs @@ -8,7 +8,7 @@ define_index_type! { } bitflags! { - #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] + #[derive(Debug, Clone, Copy)] pub struct ScopeFlags: u16 { const StrictMode = 1 << 0; const Top = 1 << 1; diff --git a/crates/oxc_syntax/src/symbol.rs b/crates/oxc_syntax/src/symbol.rs index 99629d03a..8a2960942 100644 --- a/crates/oxc_syntax/src/symbol.rs +++ b/crates/oxc_syntax/src/symbol.rs @@ -8,7 +8,7 @@ define_index_type! { } bitflags! { - #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] + #[derive(Debug, Clone, Copy)] pub struct SymbolFlags: u32 { const None = 0; /// Variable (var) or parameter