diff --git a/Cargo.lock b/Cargo.lock index 4f477ceb4d..f2cffcef08 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1295,12 +1295,6 @@ dependencies = [ "static_assertions", ] -[[package]] -name = "nohash-hasher" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451" - [[package]] name = "nom" version = "7.1.3" @@ -1895,7 +1889,6 @@ dependencies = [ "log", "memchr", "natord", - "nohash-hasher", "num-bigint", "num-traits", "once_cell", @@ -2164,7 +2157,6 @@ version = "0.0.0" dependencies = [ "bitflags 2.3.3", "is-macro", - "nohash-hasher", "num-traits", "ruff_index", "ruff_python_ast", diff --git a/Cargo.toml b/Cargo.toml index 51a34651bc..a7b55367a5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,7 +26,6 @@ is-macro = { version = "0.2.2" } itertools = { version = "0.10.5" } log = { version = "0.4.17" } memchr = "2.5.0" -nohash-hasher = { version = "0.2.0" } num-bigint = { version = "0.4.3" } num-traits = { version = "0.2.15" } once_cell = { version = "1.17.1" } diff --git a/crates/ruff/Cargo.toml b/crates/ruff/Cargo.toml index 31f80dd093..e3b52e0e76 100644 --- a/crates/ruff/Cargo.toml +++ b/crates/ruff/Cargo.toml @@ -45,7 +45,6 @@ libcst = { workspace = true } log = { workspace = true } memchr = { workspace = true } natord = { version = "1.0.9" } -nohash-hasher = { workspace = true } num-bigint = { workspace = true } num-traits = { workspace = true } once_cell = { workspace = true } diff --git a/crates/ruff/src/autofix/mod.rs b/crates/ruff/src/autofix/mod.rs index a666171b54..3aba3eb424 100644 --- a/crates/ruff/src/autofix/mod.rs +++ b/crates/ruff/src/autofix/mod.rs @@ -1,9 +1,8 @@ use std::collections::BTreeSet; use itertools::Itertools; -use nohash_hasher::IntSet; use ruff_text_size::{TextLen, TextRange, TextSize}; -use rustc_hash::FxHashMap; +use rustc_hash::{FxHashMap, FxHashSet}; use ruff_diagnostics::{Diagnostic, Edit, Fix, IsolationLevel}; use ruff_python_ast::source_code::Locator; @@ -47,7 +46,7 @@ fn apply_fixes<'a>( let mut output = String::with_capacity(locator.len()); let mut last_pos: Option = None; let mut applied: BTreeSet<&Edit> = BTreeSet::default(); - let mut isolated: IntSet = IntSet::default(); + let mut isolated: FxHashSet = FxHashSet::default(); let mut fixed = FxHashMap::default(); let mut source_map = SourceMap::default(); diff --git a/crates/ruff_python_semantic/Cargo.toml b/crates/ruff_python_semantic/Cargo.toml index 93c47dae9d..08d7ab19c2 100644 --- a/crates/ruff_python_semantic/Cargo.toml +++ b/crates/ruff_python_semantic/Cargo.toml @@ -20,7 +20,6 @@ ruff_index = { path = "../ruff_index" } bitflags = { workspace = true } is-macro = { workspace = true } -nohash-hasher = { workspace = true } num-traits = { workspace = true } rustc-hash = { workspace = true } rustpython-parser = { workspace = true } diff --git a/crates/ruff_python_semantic/src/binding.rs b/crates/ruff_python_semantic/src/binding.rs index 77bf59416a..eb93d6ffbd 100644 --- a/crates/ruff_python_semantic/src/binding.rs +++ b/crates/ruff_python_semantic/src/binding.rs @@ -275,8 +275,6 @@ bitflags! { #[newtype_index] pub struct BindingId; -impl nohash_hasher::IsEnabled for BindingId {} - /// The bindings in a program. /// /// Bindings are indexed by [`BindingId`] diff --git a/crates/ruff_python_semantic/src/model.rs b/crates/ruff_python_semantic/src/model.rs index 61726598d9..5171ff0b84 100644 --- a/crates/ruff_python_semantic/src/model.rs +++ b/crates/ruff_python_semantic/src/model.rs @@ -1,9 +1,8 @@ -use std::collections::HashMap; use std::path::Path; use bitflags::bitflags; -use nohash_hasher::{BuildNoHashHasher, IntMap}; use ruff_text_size::TextRange; +use rustc_hash::FxHashMap; use rustpython_parser::ast::{Expr, Ranged, Stmt}; use smallvec::SmallVec; @@ -74,7 +73,7 @@ pub struct SemanticModel<'a> { /// /// In this case, the binding created by `x = 1` shadows the binding created by `import x`, /// despite the fact that they're in different scopes. - pub shadowed_bindings: HashMap>, + pub shadowed_bindings: FxHashMap, /// Map from binding index to indexes of bindings that annotate it (in the same scope). /// @@ -97,7 +96,7 @@ pub struct SemanticModel<'a> { /// In this case, we _do_ store the binding created by `x: int` directly on the scope, and not /// as a delayed annotation. Annotations are thus treated as bindings only when they are the /// first binding in a scope; any annotations that follow are treated as "delayed" annotations. - delayed_annotations: HashMap, BuildNoHashHasher>, + delayed_annotations: FxHashMap>, /// Map from binding ID to the IDs of all scopes in which it is declared a `global` or /// `nonlocal`. @@ -112,7 +111,7 @@ pub struct SemanticModel<'a> { /// /// In this case, the binding created by `x = 1` is rebound within the scope created by `f` /// by way of the `global x` statement. - rebinding_scopes: HashMap, BuildNoHashHasher>, + rebinding_scopes: FxHashMap>, /// Flags for the semantic model. pub flags: SemanticModelFlags, @@ -137,9 +136,9 @@ impl<'a> SemanticModel<'a> { resolved_references: ResolvedReferences::default(), unresolved_references: UnresolvedReferences::default(), globals: GlobalsArena::default(), - shadowed_bindings: IntMap::default(), - delayed_annotations: IntMap::default(), - rebinding_scopes: IntMap::default(), + shadowed_bindings: FxHashMap::default(), + delayed_annotations: FxHashMap::default(), + rebinding_scopes: FxHashMap::default(), flags: SemanticModelFlags::new(path), handled_exceptions: Vec::default(), } diff --git a/crates/ruff_python_semantic/src/scope.rs b/crates/ruff_python_semantic/src/scope.rs index 431f22ab99..1437655a46 100644 --- a/crates/ruff_python_semantic/src/scope.rs +++ b/crates/ruff_python_semantic/src/scope.rs @@ -1,8 +1,6 @@ -use bitflags::bitflags; -use nohash_hasher::{BuildNoHashHasher, IntMap}; -use std::collections::HashMap; use std::ops::{Deref, DerefMut}; +use bitflags::bitflags; use rustc_hash::FxHashMap; use rustpython_parser::ast; @@ -37,7 +35,7 @@ pub struct Scope<'a> { /// ``` /// /// In this case, the binding created by `x = 2` shadows the binding created by `x = 1`. - shadowed_bindings: HashMap>, + shadowed_bindings: FxHashMap, /// Index into the globals arena, if the scope contains any globally-declared symbols. globals_id: Option, @@ -53,7 +51,7 @@ impl<'a> Scope<'a> { parent: None, star_imports: Vec::default(), bindings: FxHashMap::default(), - shadowed_bindings: IntMap::default(), + shadowed_bindings: FxHashMap::default(), globals_id: None, flags: ScopeFlags::empty(), } @@ -65,7 +63,7 @@ impl<'a> Scope<'a> { parent: Some(parent), star_imports: Vec::default(), bindings: FxHashMap::default(), - shadowed_bindings: IntMap::default(), + shadowed_bindings: FxHashMap::default(), globals_id: None, flags: ScopeFlags::empty(), }