diff --git a/crates/oxc_linter/src/rules/eslint/no_global_assign.rs b/crates/oxc_linter/src/rules/eslint/no_global_assign.rs index a8b3710bc5b32..6e8e3cca742ba 100644 --- a/crates/oxc_linter/src/rules/eslint/no_global_assign.rs +++ b/crates/oxc_linter/src/rules/eslint/no_global_assign.rs @@ -66,7 +66,7 @@ impl Rule for NoGlobalAssign { let reference = symbol_table.get_reference(reference_id); if reference.is_write() { let name = reference.name(); - if !self.excludes.contains(name) && ctx.env_contains_var(name) { + if !self.excludes.iter().any(|ex| ex == name) && ctx.env_contains_var(name) { ctx.diagnostic(no_global_assign_diagnostic(name, reference.span())); } } diff --git a/crates/oxc_linter/src/rules/eslint/no_undef.rs b/crates/oxc_linter/src/rules/eslint/no_undef.rs index 4315a53557a4a..ce80d41b8ee3b 100644 --- a/crates/oxc_linter/src/rules/eslint/no_undef.rs +++ b/crates/oxc_linter/src/rules/eslint/no_undef.rs @@ -58,7 +58,7 @@ impl Rule for NoUndef { continue; } - if ctx.globals().is_enabled(name.as_str()) { + if ctx.globals().is_enabled(name) { continue; } diff --git a/crates/oxc_semantic/src/builder.rs b/crates/oxc_semantic/src/builder.rs index f8cb9592c5887..8b0208fe852e9 100644 --- a/crates/oxc_semantic/src/builder.rs +++ b/crates/oxc_semantic/src/builder.rs @@ -319,7 +319,7 @@ impl<'a> SemanticBuilder<'a> { reference: Reference, add_unresolved_reference: bool, ) -> ReferenceId { - let reference_name = reference.name().clone(); + let reference_name = reference.name().into(); let reference_id = self.symbols.create_reference(reference); if add_unresolved_reference { self.scope.add_unresolved_reference( @@ -328,7 +328,7 @@ impl<'a> SemanticBuilder<'a> { reference_id, ); } else { - self.resolve_reference_ids(reference_name.clone(), vec![reference_id]); + self.resolve_reference_ids(reference_name, vec![reference_id]); } reference_id } diff --git a/crates/oxc_semantic/src/reference.rs b/crates/oxc_semantic/src/reference.rs index 145f3494b0856..c46b01dd62380 100644 --- a/crates/oxc_semantic/src/reference.rs +++ b/crates/oxc_semantic/src/reference.rs @@ -43,7 +43,7 @@ impl Reference { self.span } - pub fn name(&self) -> &CompactStr { + pub fn name(&self) -> &str { &self.name } diff --git a/crates/oxc_span/src/atom.rs b/crates/oxc_span/src/atom.rs index f1cf1f239a510..3b92aa6dcbbee 100644 --- a/crates/oxc_span/src/atom.rs +++ b/crates/oxc_span/src/atom.rs @@ -98,7 +98,7 @@ impl<'a> Borrow for Atom<'a> { } } -impl<'a, T: AsRef> PartialEq for Atom<'a> { +impl<'a, T: AsRef + ?Sized> PartialEq for Atom<'a> { fn eq(&self, other: &T) -> bool { self.as_str() == other.as_ref() } @@ -110,12 +110,6 @@ impl<'a> PartialEq> for &str { } } -impl<'a> PartialEq for Atom<'a> { - fn eq(&self, other: &str) -> bool { - self.as_str() == other - } -} - impl<'a> hash::Hash for Atom<'a> { fn hash(&self, hasher: &mut H) { self.as_str().hash(hasher); @@ -254,7 +248,7 @@ impl Borrow for CompactStr { } } -impl> PartialEq for CompactStr { +impl + ?Sized> PartialEq for CompactStr { fn eq(&self, other: &T) -> bool { self.as_str() == other.as_ref() } diff --git a/crates/oxc_traverse/src/context/scoping.rs b/crates/oxc_traverse/src/context/scoping.rs index 0c6282a028dbd..3c36f66f10f2c 100644 --- a/crates/oxc_traverse/src/context/scoping.rs +++ b/crates/oxc_traverse/src/context/scoping.rs @@ -459,7 +459,7 @@ impl TraverseScoping { // which already checked above false } else { - reference.name().as_str() == name + reference.name() == name } }) }