Skip to content
Merged
1 change: 0 additions & 1 deletion Cargo.lock

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

8 changes: 6 additions & 2 deletions crates/ruff_db/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ ty_static = { workspace = true }
anstyle = { workspace = true }
arc-swap = { workspace = true }
camino = { workspace = true }
countme = { workspace = true }
dashmap = { workspace = true }
dunce = { workspace = true }
filetime = { workspace = true }
Expand Down Expand Up @@ -59,6 +58,11 @@ tempfile = { workspace = true }
cache = ["ruff_cache"]
junit = ["dep:quick-junit"]
os = ["ignore", "dep:etcetera"]
serde = ["camino/serde1", "dep:serde", "dep:serde_json", "ruff_diagnostics/serde"]
serde = [
"camino/serde1",
"dep:serde",
"dep:serde_json",
"ruff_diagnostics/serde",
]
# Exposes testing utilities.
testing = ["tracing-subscriber"]
6 changes: 0 additions & 6 deletions crates/ruff_db/src/files.rs
Copy link
Member Author

@MichaReiser MichaReiser Jul 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, you got me. I tried to sneak in a change here. I removed countme. I re-added it to ty_python_semantic to gather some statistics and then removed it when cleaning up this PR, which is when I realized that I missed to remove these countme fields in ruff_db. We no longer need to use countme because TY_MEMORY_REPORT exposes the same information (and much more!)

Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use std::fmt;
use std::sync::Arc;

use countme::Count;
use dashmap::mapref::entry::Entry;
pub use file_root::{FileRoot, FileRootKind};
pub use path::FilePath;
Expand Down Expand Up @@ -312,11 +311,6 @@ pub struct File {
/// the file has been deleted is to change the status to `Deleted`.
#[default]
status: FileStatus,

/// Counter that counts the number of created file instances and active file instances.
/// Only enabled in debug builds.
#[default]
count: Count<File>,
}

// The Salsa heap is tracked separately.
Expand Down
10 changes: 1 addition & 9 deletions crates/ruff_db/src/source.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
use std::ops::Deref;
use std::sync::Arc;

use countme::Count;

use ruff_notebook::Notebook;
use ruff_python_ast::PySourceType;
use ruff_source_file::LineIndex;
Expand Down Expand Up @@ -38,11 +36,7 @@ pub fn source_text(db: &dyn Db, file: File) -> SourceText {
};

SourceText {
inner: Arc::new(SourceTextInner {
kind,
read_error,
count: Count::new(),
}),
inner: Arc::new(SourceTextInner { kind, read_error }),
}
}

Expand Down Expand Up @@ -125,8 +119,6 @@ impl std::fmt::Debug for SourceText {

#[derive(Eq, PartialEq, get_size2::GetSize)]
struct SourceTextInner {
#[get_size(ignore)]
count: Count<SourceText>,
kind: SourceTextKind,
read_error: Option<SourceTextError>,
}
Expand Down
7 changes: 5 additions & 2 deletions crates/ty_python_semantic/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,10 @@ pub fn check_types(db: &dyn Db, file: File) -> Vec<Diagnostic> {

for scope_id in index.scope_ids() {
let result = infer_scope_types(db, scope_id);
diagnostics.extend(result.diagnostics());

if let Some(scope_diagnostics) = result.diagnostics() {
diagnostics.extend(scope_diagnostics);
}
}

diagnostics.extend_diagnostics(
Expand All @@ -115,7 +118,7 @@ pub fn check_types(db: &dyn Db, file: File) -> Vec<Diagnostic> {

check_suppressions(db, file, &mut diagnostics);

diagnostics.into_vec()
diagnostics.into_diagnostics()
}

/// Infer the type of a binding.
Expand Down
2 changes: 1 addition & 1 deletion crates/ty_python_semantic/src/types/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use crate::{
/// ## Consuming
/// It's important that the context is explicitly consumed before dropping by calling
/// [`InferContext::finish`] and the returned diagnostics must be stored
/// on the current [`TypeInference`](super::infer::TypeInference) result.
/// on the current [`TypeInferenceBuilder`](super::infer::TypeInferenceBuilder) result.
pub(crate) struct InferContext<'db, 'ast> {
db: &'db dyn Db,
scope: ScopeId<'db>,
Expand Down
19 changes: 14 additions & 5 deletions crates/ty_python_semantic/src/types/diagnostic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1671,18 +1671,26 @@ impl TypeCheckDiagnostics {
self.diagnostics.shrink_to_fit();
}

pub(crate) fn into_vec(self) -> Vec<Diagnostic> {
pub(crate) fn into_diagnostics(self) -> Vec<Diagnostic> {
self.diagnostics
}

pub(crate) fn is_empty(&self) -> bool {
self.diagnostics.is_empty() && self.used_suppressions.is_empty()
}

pub fn iter(&self) -> std::slice::Iter<'_, Diagnostic> {
self.diagnostics.iter()
self.diagnostics().iter()
}

fn diagnostics(&self) -> &[Diagnostic] {
self.diagnostics.as_slice()
}
}

impl std::fmt::Debug for TypeCheckDiagnostics {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
self.diagnostics.fmt(f)
self.diagnostics().fmt(f)
}
}

Expand All @@ -1691,16 +1699,17 @@ impl IntoIterator for TypeCheckDiagnostics {
type IntoIter = std::vec::IntoIter<Diagnostic>;

fn into_iter(self) -> Self::IntoIter {
self.diagnostics.into_iter()
self.into_diagnostics().into_iter()
}
}

impl<'a> IntoIterator for &'a TypeCheckDiagnostics {
type Item = &'a Diagnostic;
type IntoIter = std::slice::Iter<'a, Diagnostic>;

#[inline]
fn into_iter(self) -> Self::IntoIter {
self.diagnostics.iter()
self.iter()
}
}

Expand Down
Loading
Loading