Skip to content
Open
Show file tree
Hide file tree
Changes from 5 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
6 changes: 1 addition & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion crates/ruff_benchmark/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -88,5 +88,4 @@ mimalloc = { workspace = true }
tikv-jemallocator = { workspace = true }

[dev-dependencies]
rustc-hash = { workspace = true }
rayon = { workspace = true }
3 changes: 1 addition & 2 deletions crates/ruff_benchmark/benches/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use std::ops::Range;

use criterion::{BatchSize, Criterion, criterion_group, criterion_main};
use rayon::ThreadPoolBuilder;
use rustc_hash::FxHashSet;

use ruff_benchmark::TestFile;
use ruff_db::diagnostic::{Diagnostic, DiagnosticId, Severity};
Expand All @@ -18,7 +17,7 @@ use ruff_python_ast::PythonVersion;
use ty_project::metadata::options::{EnvironmentOptions, Options};
use ty_project::metadata::value::{RangedValue, RelativePathBuf};
use ty_project::watch::{ChangeEvent, ChangedKind};
use ty_project::{CheckMode, Db, ProjectDatabase, ProjectMetadata};
use ty_project::{CheckMode, Db, FxHashSet, ProjectDatabase, ProjectMetadata};

struct Case {
db: ProjectDatabase,
Expand Down
1 change: 0 additions & 1 deletion crates/ty_ide/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ get-size2 = { workspace = true }
itertools = { workspace = true }
rayon = { workspace = true }
regex = { workspace = true }
rustc-hash = { workspace = true }
salsa = { workspace = true, features = ["compact_str"] }
smallvec = { workspace = true }
tracing = { workspace = true }
Expand Down
4 changes: 2 additions & 2 deletions crates/ty_ide/src/importer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ The main differences here are:
3. It doesn't have as many facilities as `ruff_linter`'s importer.
*/

use rustc_hash::FxHashMap;
use ty_python_semantic::FxHashMap;

use ruff_db::files::File;
use ruff_db::parsed::ParsedModuleRef;
Expand Down Expand Up @@ -325,7 +325,7 @@ impl<'ast> MembersInScope<'ast> {
let model = SemanticModel::new(db, file);
let map = model
.members_in_scope_at(node)
.into_iter()
.stable_into_iter()
.map(|(name, memberdef)| {
let Some(def) = memberdef.definition else {
return (name, MemberInScope::other(memberdef.ty));
Expand Down
4 changes: 2 additions & 2 deletions crates/ty_ide/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ use ruff_db::{
vendored::VendoredPath,
};
use ruff_text_size::{Ranged, TextRange};
use rustc_hash::FxHashSet;
use std::ops::{Deref, DerefMut};
use ty_project::Db;
use ty_python_semantic::FxHashSet;
use ty_python_semantic::types::{Type, TypeDefinition};

/// Information associated with a text range.
Expand Down Expand Up @@ -216,7 +216,7 @@ impl NavigationTargets {
if unique.is_empty() {
Self::empty()
} else {
let mut targets = unique.into_iter().collect::<Vec<_>>();
let mut targets = unique.unstable_into_iter().collect::<Vec<_>>();
targets.sort_by_key(|target| (target.file, target.focus_range.start()));
Self(targets.into())
}
Expand Down
2 changes: 1 addition & 1 deletion crates/ty_ide/src/workspace_symbols.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub fn workspace_symbols(db: &dyn Db, query: &str) -> Vec<WorkspaceSymbolInfo> {

rayon::scope(move |s| {
// For each file, extract symbols and add them to results
for file in files.iter() {
for file in files.unstable_iter() {
let db = db.dyn_clone();
s.spawn(move |_| {
for (_, symbol) in symbols_for_file_global_only(&*db, *file).search(query) {
Expand Down
1 change: 0 additions & 1 deletion crates/ty_project/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ ordermap = { workspace = true, features = ["serde"] }
rayon = { workspace = true }
regex = { workspace = true }
regex-automata = { workspace = true }
rustc-hash = { workspace = true }
salsa = { workspace = true }
schemars = { workspace = true, optional = true }
serde = { workspace = true }
Expand Down
6 changes: 4 additions & 2 deletions crates/ty_project/src/db/changes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ use ruff_db::Db as _;
use ruff_db::file_revision::FileRevision;
use ruff_db::files::{File, FileRootKind, Files};
use ruff_db::system::SystemPath;
use rustc_hash::FxHashSet;
use salsa::Setter;
use ty_python_semantic::FxHashSet;
use ty_python_semantic::Program;

/// Represents the result of applying changes to the project database.
Expand Down Expand Up @@ -317,7 +317,9 @@ impl ProjectDatabase {
}
}

let diagnostics = if let Some(walker) = ProjectFilesWalker::incremental(self, added_paths) {
let diagnostics = if let Some(walker) =
ProjectFilesWalker::incremental(self, added_paths.stable_iter())
{
// Use directory walking to discover newly added files.
let (files, diagnostics) = walker.collect_vec(self);

Expand Down
10 changes: 5 additions & 5 deletions crates/ty_project/src/files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use std::marker::PhantomData;
use std::ops::Deref;
use std::sync::Arc;

use rustc_hash::FxHashSet;
use salsa::Setter;
use ty_python_semantic::FxHashSet;

use ruff_db::files::File;

Expand Down Expand Up @@ -181,7 +181,7 @@ impl<'a> IntoIterator for &'a Indexed<'_> {
type IntoIter = IndexedIter<'a>;

fn into_iter(self) -> Self::IntoIter {
self.inner.files.iter().copied()
self.inner.files.unstable_iter().copied()
}
}

Expand Down Expand Up @@ -251,7 +251,7 @@ impl Drop for IndexedMut<'_> {

#[cfg(test)]
mod tests {
use rustc_hash::FxHashSet;
use ty_python_semantic::FxHashSet;

use crate::ProjectMetadata;
use crate::db::Db;
Expand Down Expand Up @@ -288,8 +288,8 @@ mod tests {
}
Index::Indexed(files_2) => {
assert_eq!(
files_2.iter().collect::<Vec<_>>(),
files.iter().collect::<Vec<_>>()
files_2.unstable_iter().collect::<Vec<_>>(),
files.unstable_iter().collect::<Vec<_>>()
);
}
}
Expand Down
4 changes: 2 additions & 2 deletions crates/ty_project/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ use ruff_db::files::{File, FileRootKind};
use ruff_db::parsed::parsed_module;
use ruff_db::source::{SourceTextError, source_text};
use ruff_db::system::{SystemPath, SystemPathBuf};
use rustc_hash::FxHashSet;
use salsa::Durability;
use salsa::Setter;
use std::backtrace::BacktraceStatus;
Expand All @@ -31,6 +30,7 @@ use tracing::error;
use ty_python_semantic::add_inferred_python_version_hint_to_diagnostic;
use ty_python_semantic::lint::RuleSelection;
use ty_python_semantic::types::check_types;
pub use ty_python_semantic::{FxHashMap, FxHashSet};

mod db;
mod files;
Expand Down Expand Up @@ -620,7 +620,7 @@ impl<'a> IntoIterator for &'a ProjectFiles<'a> {

fn into_iter(self) -> Self::IntoIter {
match self {
ProjectFiles::OpenFiles(files) => ProjectFilesIter::OpenFiles(files.iter()),
ProjectFiles::OpenFiles(files) => ProjectFilesIter::OpenFiles(files.unstable_iter()),
ProjectFiles::Indexed(files) => ProjectFilesIter::Indexed(files.into_iter()),
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/ty_project/src/metadata/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ use ruff_db::vendored::VendoredFileSystem;
use ruff_macros::{Combine, OptionsMetadata, RustDoc};
use ruff_options_metadata::{OptionSet, OptionsMetadata, Visit};
use ruff_python_ast::PythonVersion;
use rustc_hash::FxHasher;
use serde::{Deserialize, Serialize};
use std::borrow::Cow;
use std::fmt::{self, Debug, Display};
Expand All @@ -28,6 +27,7 @@ use std::ops::Deref;
use std::sync::Arc;
use thiserror::Error;
use ty_combine::Combine;
use ty_python_semantic::FxHasher;
use ty_python_semantic::lint::{Level, LintSource, RuleSelection};
use ty_python_semantic::{
ProgramSettings, PythonEnvironment, PythonPlatform, PythonVersionFileSource,
Expand Down
2 changes: 1 addition & 1 deletion crates/ty_project/src/walk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ use ruff_db::files::{File, system_path_to_file};
use ruff_db::system::walk_directory::{ErrorKind, WalkDirectoryBuilder, WalkState};
use ruff_db::system::{SystemPath, SystemPathBuf};
use ruff_python_ast::PySourceType;
use rustc_hash::FxHashSet;
use std::path::PathBuf;
use thiserror::Error;
use ty_python_semantic::FxHashSet;

/// Filter that decides which files are included in the project.
///
Expand Down
1 change: 1 addition & 0 deletions crates/ty_python_semantic/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ memchr = { workspace = true }
strum = { workspace = true }
strum_macros = { workspace = true }
strsim = "0.11.1"
url = { workspace = true }

[dev-dependencies]
ruff_db = { workspace = true, features = ["testing", "os"] }
Expand Down
11 changes: 5 additions & 6 deletions crates/ty_python_semantic/src/dunder_all.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use rustc_hash::FxHashSet;

use ruff_db::files::File;
use ruff_db::parsed::parsed_module;
use ruff_python_ast::name::Name;
Expand All @@ -8,7 +6,7 @@ use ruff_python_ast::{self as ast};

use crate::semantic_index::{SemanticIndex, semantic_index};
use crate::types::{Truthiness, Type, TypeContext, infer_expression_types};
use crate::{Db, ModuleName, resolve_module};
use crate::{Db, FxHashSet, ModuleName, resolve_module};

fn dunder_all_names_cycle_initial(
_db: &dyn Db,
Expand Down Expand Up @@ -103,7 +101,8 @@ impl<'db> DunderAllNamesCollector<'db> {
// The module either does not have a `__all__` variable or it is invalid.
return false;
};
self.names.extend(module_dunder_all_names.iter().cloned());
self.names
.extend(module_dunder_all_names.stable_iter().cloned());
true
}

Expand Down Expand Up @@ -240,7 +239,7 @@ impl<'db> StatementVisitor<'db> for DunderAllNamesCollector<'db> {

if all_names.contains(&Name::new_static("__all__")) {
self.update_origin(DunderAllOrigin::StarImport);
self.names.extend(all_names.iter().cloned());
self.names.extend(all_names.stable_iter().cloned());
}
} else {
// `from module import __all__`
Expand Down Expand Up @@ -270,7 +269,7 @@ impl<'db> StatementVisitor<'db> for DunderAllNamesCollector<'db> {
};

self.update_origin(DunderAllOrigin::ExternalModule);
self.names.extend(all_names.iter().cloned());
self.names.extend(all_names.stable_iter().cloned());
}
}
}
Expand Down
Loading