Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/oxc_linter/src/rules/eslint/no_global_assign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_linter/src/rules/eslint/no_undef.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ impl Rule for NoUndef {
continue;
}

if ctx.globals().is_enabled(name.as_str()) {
if ctx.globals().is_enabled(name) {
continue;
}

Expand Down
4 changes: 2 additions & 2 deletions crates/oxc_semantic/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_semantic/src/reference.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ impl Reference {
self.span
}

pub fn name(&self) -> &CompactStr {
pub fn name(&self) -> &str {
&self.name
}

Expand Down
10 changes: 2 additions & 8 deletions crates/oxc_span/src/atom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ impl<'a> Borrow<str> for Atom<'a> {
}
}

impl<'a, T: AsRef<str>> PartialEq<T> for Atom<'a> {
impl<'a, T: AsRef<str> + ?Sized> PartialEq<T> for Atom<'a> {
fn eq(&self, other: &T) -> bool {
self.as_str() == other.as_ref()
}
Expand All @@ -110,12 +110,6 @@ impl<'a> PartialEq<Atom<'a>> for &str {
}
}

impl<'a> PartialEq<str> for Atom<'a> {
fn eq(&self, other: &str) -> bool {
self.as_str() == other
}
}

impl<'a> hash::Hash for Atom<'a> {
fn hash<H: hash::Hasher>(&self, hasher: &mut H) {
self.as_str().hash(hasher);
Expand Down Expand Up @@ -254,7 +248,7 @@ impl Borrow<str> for CompactStr {
}
}

impl<T: AsRef<str>> PartialEq<T> for CompactStr {
impl<T: AsRef<str> + ?Sized> PartialEq<T> for CompactStr {
fn eq(&self, other: &T) -> bool {
self.as_str() == other.as_ref()
}
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_traverse/src/context/scoping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ impl TraverseScoping {
// which already checked above
false
} else {
reference.name().as_str() == name
reference.name() == name
}
})
}
Expand Down