diff --git a/crates/ruff_db/src/parsed.rs b/crates/ruff_db/src/parsed.rs index dd98114e3a..7c12cb5f90 100644 --- a/crates/ruff_db/src/parsed.rs +++ b/crates/ruff_db/src/parsed.rs @@ -21,7 +21,7 @@ use crate::source::source_text; /// reflected in the changed AST offsets. /// The other reason is that Ruff's AST doesn't implement `Eq` which Salsa requires /// for determining if a query result is unchanged. -#[salsa::tracked(returns(ref), no_eq, heap_size=get_size2::GetSize::get_heap_size)] +#[salsa::tracked(returns(ref), no_eq, heap_size=get_size2::heap_size)] pub fn parsed_module(db: &dyn Db, file: File) -> ParsedModule { let _span = tracing::trace_span!("parsed_module", ?file).entered(); diff --git a/crates/ruff_db/src/source.rs b/crates/ruff_db/src/source.rs index ca303e6bbd..a6a7e9d635 100644 --- a/crates/ruff_db/src/source.rs +++ b/crates/ruff_db/src/source.rs @@ -9,7 +9,7 @@ use crate::Db; use crate::files::{File, FilePath}; /// Reads the source text of a python text file (must be valid UTF8) or notebook. -#[salsa::tracked(heap_size=get_size2::GetSize::get_heap_size)] +#[salsa::tracked(heap_size=get_size2::heap_size)] pub fn source_text(db: &dyn Db, file: File) -> SourceText { let path = file.path(db); let _span = tracing::trace_span!("source_text", file = %path).entered(); @@ -69,21 +69,21 @@ impl SourceText { pub fn as_str(&self) -> &str { match &self.inner.kind { SourceTextKind::Text(source) => source, - SourceTextKind::Notebook(notebook) => notebook.source_code(), + SourceTextKind::Notebook { notebook } => notebook.source_code(), } } /// Returns the underlying notebook if this is a notebook file. pub fn as_notebook(&self) -> Option<&Notebook> { match &self.inner.kind { - SourceTextKind::Notebook(notebook) => Some(notebook), + SourceTextKind::Notebook { notebook } => Some(notebook), SourceTextKind::Text(_) => None, } } /// Returns `true` if this is a notebook source file. pub fn is_notebook(&self) -> bool { - matches!(&self.inner.kind, SourceTextKind::Notebook(_)) + matches!(&self.inner.kind, SourceTextKind::Notebook { .. }) } /// Returns `true` if there was an error when reading the content of the file. @@ -108,7 +108,7 @@ impl std::fmt::Debug for SourceText { SourceTextKind::Text(text) => { dbg.field(text); } - SourceTextKind::Notebook(notebook) => { + SourceTextKind::Notebook { notebook } => { dbg.field(notebook); } } @@ -123,23 +123,15 @@ struct SourceTextInner { read_error: Option, } -#[derive(Eq, PartialEq)] +#[derive(Eq, PartialEq, get_size2::GetSize)] enum SourceTextKind { Text(String), - Notebook(Box), -} - -impl get_size2::GetSize for SourceTextKind { - fn get_heap_size(&self) -> usize { - match self { - SourceTextKind::Text(text) => text.get_heap_size(), - // TODO: The `get-size` derive does not support ignoring enum variants. - // - // Jupyter notebooks are not very relevant for memory profiling, and contain - // arbitrary JSON values that do not implement the `GetSize` trait. - SourceTextKind::Notebook(_) => 0, - } - } + Notebook { + // Jupyter notebooks are not very relevant for memory profiling, and contain + // arbitrary JSON values that do not implement the `GetSize` trait. + #[get_size(ignore)] + notebook: Box, + }, } impl From for SourceTextKind { @@ -150,7 +142,9 @@ impl From for SourceTextKind { impl From for SourceTextKind { fn from(notebook: Notebook) -> Self { - SourceTextKind::Notebook(Box::new(notebook)) + SourceTextKind::Notebook { + notebook: Box::new(notebook), + } } } @@ -163,7 +157,7 @@ pub enum SourceTextError { } /// Computes the [`LineIndex`] for `file`. -#[salsa::tracked(heap_size=get_size2::GetSize::get_heap_size)] +#[salsa::tracked(heap_size=get_size2::heap_size)] pub fn line_index(db: &dyn Db, file: File) -> LineIndex { let _span = tracing::trace_span!("line_index", ?file).entered(); diff --git a/crates/ty_project/src/lib.rs b/crates/ty_project/src/lib.rs index 373131ff96..4822b1679e 100644 --- a/crates/ty_project/src/lib.rs +++ b/crates/ty_project/src/lib.rs @@ -174,7 +174,7 @@ impl Project { /// This is a salsa query to prevent re-computing queries if other, unrelated /// settings change. For example, we don't want that changing the terminal settings /// invalidates any type checking queries. - #[salsa::tracked(returns(deref), heap_size=get_size2::GetSize::get_heap_size)] + #[salsa::tracked(returns(deref), heap_size=get_size2::heap_size)] pub fn rules(self, db: &dyn Db) -> Arc { self.settings(db).to_rules() } @@ -511,7 +511,7 @@ impl Project { } } -#[salsa::tracked(returns(ref), heap_size=get_size2::GetSize::get_heap_size)] +#[salsa::tracked(returns(ref), heap_size=get_size2::heap_size)] pub(crate) fn check_file_impl(db: &dyn Db, file: File) -> Result, Diagnostic> { let mut diagnostics: Vec = Vec::new(); diff --git a/crates/ty_project/src/metadata/settings.rs b/crates/ty_project/src/metadata/settings.rs index 1c5221e9cc..aa4196fafb 100644 --- a/crates/ty_project/src/metadata/settings.rs +++ b/crates/ty_project/src/metadata/settings.rs @@ -96,7 +96,7 @@ impl Override { } /// Resolves the settings for a given file. -#[salsa::tracked(returns(ref), heap_size=get_size2::GetSize::get_heap_size)] +#[salsa::tracked(returns(ref), heap_size=get_size2::heap_size)] pub(crate) fn file_settings(db: &dyn Db, file: File) -> FileSettings { let settings = db.project().settings(db); @@ -155,7 +155,7 @@ pub(crate) fn file_settings(db: &dyn Db, file: File) -> FileSettings { /// This is to make Salsa happy because it requires that queries with only a single argument /// take a salsa-struct as argument, which isn't the case here. The `()` enables salsa's /// automatic interning for the arguments. -#[salsa::tracked(heap_size=get_size2::GetSize::get_heap_size)] +#[salsa::tracked(heap_size=get_size2::heap_size)] fn merge_overrides(db: &dyn Db, overrides: Vec>, _: ()) -> FileSettings { let mut overrides = overrides.into_iter().rev(); let mut merged = (*overrides.next().unwrap()).clone(); diff --git a/crates/ty_python_semantic/src/dunder_all.rs b/crates/ty_python_semantic/src/dunder_all.rs index e99df234e4..1cf0f50ea6 100644 --- a/crates/ty_python_semantic/src/dunder_all.rs +++ b/crates/ty_python_semantic/src/dunder_all.rs @@ -26,7 +26,7 @@ fn dunder_all_names_cycle_initial(_db: &dyn Db, _file: File) -> Option Option> { let _span = tracing::trace_span!("dunder_all_names", file=?file.path(db)).entered(); diff --git a/crates/ty_python_semantic/src/module_resolver/resolver.rs b/crates/ty_python_semantic/src/module_resolver/resolver.rs index a29af76c2c..fca6ae8f1b 100644 --- a/crates/ty_python_semantic/src/module_resolver/resolver.rs +++ b/crates/ty_python_semantic/src/module_resolver/resolver.rs @@ -61,7 +61,7 @@ impl ModuleResolveMode { /// /// This query should not be called directly. Instead, use [`resolve_module`]. It only exists /// because Salsa requires the module name to be an ingredient. -#[salsa::tracked(heap_size=get_size2::GetSize::get_heap_size)] +#[salsa::tracked(heap_size=get_size2::heap_size)] fn resolve_module_query<'db>( db: &'db dyn Db, module_name: ModuleNameIngredient<'db>, @@ -118,7 +118,7 @@ pub(crate) fn path_to_module<'db>(db: &'db dyn Db, path: &FilePath) -> Option Option> { let _span = tracing::trace_span!("file_to_module", ?file).entered(); @@ -322,7 +322,7 @@ impl SearchPaths { /// The editable-install search paths for the first `site-packages` directory /// should come between the two `site-packages` directories when it comes to /// module-resolution priority. -#[salsa::tracked(returns(deref), heap_size=get_size2::GetSize::get_heap_size)] +#[salsa::tracked(returns(deref), heap_size=get_size2::heap_size)] pub(crate) fn dynamic_resolution_paths(db: &dyn Db) -> Vec { tracing::debug!("Resolving dynamic module resolution paths"); diff --git a/crates/ty_python_semantic/src/place.rs b/crates/ty_python_semantic/src/place.rs index 14dadba5bf..9e3e2d04cf 100644 --- a/crates/ty_python_semantic/src/place.rs +++ b/crates/ty_python_semantic/src/place.rs @@ -641,7 +641,7 @@ fn place_cycle_initial<'db>( Place::bound(Type::Never).into() } -#[salsa::tracked(cycle_fn=place_cycle_recover, cycle_initial=place_cycle_initial, heap_size=get_size2::GetSize::get_heap_size)] +#[salsa::tracked(cycle_fn=place_cycle_recover, cycle_initial=place_cycle_initial, heap_size=get_size2::heap_size)] fn place_by_id<'db>( db: &'db dyn Db, scope: ScopeId<'db>, @@ -1368,7 +1368,7 @@ mod implicit_globals { /// Conceptually this function could be a `Set` rather than a list, /// but the number of symbols declared in this scope is likely to be very small, /// so the cost of hashing the names is likely to be more expensive than it's worth. - #[salsa::tracked(returns(deref), heap_size=get_size2::GetSize::get_heap_size)] + #[salsa::tracked(returns(deref), heap_size=get_size2::heap_size)] fn module_type_symbols<'db>(db: &'db dyn Db) -> smallvec::SmallVec<[ast::name::Name; 8]> { let Some(module_type) = KnownClass::ModuleType .to_class_literal(db) diff --git a/crates/ty_python_semantic/src/semantic_index.rs b/crates/ty_python_semantic/src/semantic_index.rs index ef86c22b3c..90abb34ce5 100644 --- a/crates/ty_python_semantic/src/semantic_index.rs +++ b/crates/ty_python_semantic/src/semantic_index.rs @@ -52,7 +52,7 @@ pub(crate) use self::use_def::{ /// Returns the semantic index for `file`. /// /// Prefer using [`symbol_table`] when working with symbols from a single scope. -#[salsa::tracked(returns(ref), no_eq, heap_size=get_size2::GetSize::get_heap_size)] +#[salsa::tracked(returns(ref), no_eq, heap_size=get_size2::heap_size)] pub(crate) fn semantic_index(db: &dyn Db, file: File) -> SemanticIndex<'_> { let _span = tracing::trace_span!("semantic_index", ?file).entered(); @@ -66,7 +66,7 @@ pub(crate) fn semantic_index(db: &dyn Db, file: File) -> SemanticIndex<'_> { /// Using [`place_table`] over [`semantic_index`] has the advantage that /// Salsa can avoid invalidating dependent queries if this scope's place table /// is unchanged. -#[salsa::tracked(returns(deref), heap_size=get_size2::GetSize::get_heap_size)] +#[salsa::tracked(returns(deref), heap_size=get_size2::heap_size)] pub(crate) fn place_table<'db>(db: &'db dyn Db, scope: ScopeId<'db>) -> Arc { let file = scope.file(db); let _span = tracing::trace_span!("place_table", scope=?scope.as_id(), ?file).entered(); @@ -86,7 +86,7 @@ pub(crate) fn place_table<'db>(db: &'db dyn Db, scope: ScopeId<'db>) -> Arc(db: &'db dyn Db, file: File) -> Arc> { semantic_index(db, file).imported_modules.clone() } @@ -96,7 +96,7 @@ pub(crate) fn imported_modules<'db>(db: &'db dyn Db, file: File) -> Arc(db: &'db dyn Db, scope: ScopeId<'db>) -> ArcUseDefMap<'db> { let file = scope.file(db); let _span = tracing::trace_span!("use_def_map", scope=?scope.as_id(), ?file).entered(); @@ -184,7 +184,7 @@ pub(crate) fn attribute_scopes<'db, 's>( } /// Returns the module global scope of `file`. -#[salsa::tracked(heap_size=get_size2::GetSize::get_heap_size)] +#[salsa::tracked(heap_size=get_size2::heap_size)] pub(crate) fn global_scope(db: &dyn Db, file: File) -> ScopeId<'_> { let _span = tracing::trace_span!("global_scope", ?file).entered(); diff --git a/crates/ty_python_semantic/src/semantic_index/re_exports.rs b/crates/ty_python_semantic/src/semantic_index/re_exports.rs index ba8a912fac..909ec1a69a 100644 --- a/crates/ty_python_semantic/src/semantic_index/re_exports.rs +++ b/crates/ty_python_semantic/src/semantic_index/re_exports.rs @@ -43,7 +43,7 @@ fn exports_cycle_initial(_db: &dyn Db, _file: File) -> Box<[Name]> { Box::default() } -#[salsa::tracked(returns(deref), cycle_fn=exports_cycle_recover, cycle_initial=exports_cycle_initial, heap_size=get_size2::GetSize::get_heap_size)] +#[salsa::tracked(returns(deref), cycle_fn=exports_cycle_recover, cycle_initial=exports_cycle_initial, heap_size=get_size2::heap_size)] pub(super) fn exported_names(db: &dyn Db, file: File) -> Box<[Name]> { let module = parsed_module(db, file).load(db); let mut finder = ExportFinder::new(db, file); diff --git a/crates/ty_python_semantic/src/suppression.rs b/crates/ty_python_semantic/src/suppression.rs index e357871b2d..fabfc14429 100644 --- a/crates/ty_python_semantic/src/suppression.rs +++ b/crates/ty_python_semantic/src/suppression.rs @@ -86,7 +86,7 @@ declare_lint! { } } -#[salsa::tracked(returns(ref), heap_size=get_size2::GetSize::get_heap_size)] +#[salsa::tracked(returns(ref), heap_size=get_size2::heap_size)] pub(crate) fn suppressions(db: &dyn Db, file: File) -> Suppressions { let parsed = parsed_module(db, file).load(db); let source = source_text(db, file); diff --git a/crates/ty_python_semantic/src/types.rs b/crates/ty_python_semantic/src/types.rs index a6f76a5550..76cb7f52c7 100644 --- a/crates/ty_python_semantic/src/types.rs +++ b/crates/ty_python_semantic/src/types.rs @@ -2578,7 +2578,7 @@ impl<'db> Type<'db> { } } - #[salsa::tracked(heap_size=get_size2::GetSize::get_heap_size)] + #[salsa::tracked(heap_size=get_size2::heap_size)] #[allow(unused_variables)] // If we choose name `_unit`, the macro will generate code that uses `_unit`, causing clippy to fail. fn lookup_dunder_new(self, db: &'db dyn Db, unit: ()) -> Option> { @@ -2599,7 +2599,7 @@ impl<'db> Type<'db> { self.class_member_with_policy(db, name, MemberLookupPolicy::default()) } - #[salsa::tracked(cycle_fn=class_lookup_cycle_recover, cycle_initial=class_lookup_cycle_initial, heap_size=get_size2::GetSize::get_heap_size)] + #[salsa::tracked(cycle_fn=class_lookup_cycle_recover, cycle_initial=class_lookup_cycle_initial, heap_size=get_size2::heap_size)] fn class_member_with_policy( self, db: &'db dyn Db, @@ -2760,7 +2760,7 @@ impl<'db> Type<'db> { /// that `self` represents: (1) a data descriptor or (2) a non-data descriptor / normal attribute. /// /// If `__get__` is not defined on the meta-type, this method returns `None`. - #[salsa::tracked(heap_size=get_size2::GetSize::get_heap_size)] + #[salsa::tracked(heap_size=get_size2::heap_size)] pub(crate) fn try_call_dunder_get( self, db: &'db dyn Db, @@ -3053,7 +3053,7 @@ impl<'db> Type<'db> { /// Similar to [`Type::member`], but allows the caller to specify what policy should be used /// when looking up attributes. See [`MemberLookupPolicy`] for more information. - #[salsa::tracked(cycle_fn=member_lookup_cycle_recover, cycle_initial=member_lookup_cycle_initial, heap_size=get_size2::GetSize::get_heap_size)] + #[salsa::tracked(cycle_fn=member_lookup_cycle_recover, cycle_initial=member_lookup_cycle_initial, heap_size=get_size2::heap_size)] fn member_lookup_with_policy( self, db: &'db dyn Db, @@ -5550,7 +5550,7 @@ impl<'db> Type<'db> { /// Note that this does not specialize generic classes, functions, or type aliases! That is a /// different operation that is performed explicitly (via a subscript operation), or implicitly /// via a call to the generic object. - #[salsa::tracked(heap_size=get_size2::GetSize::get_heap_size)] + #[salsa::tracked(heap_size=get_size2::heap_size)] pub fn apply_specialization( self, db: &'db dyn Db, @@ -8140,7 +8140,7 @@ impl<'db> PEP695TypeAliasType<'db> { semantic_index(db, scope.file(db)).expect_single_definition(type_alias_stmt_node) } - #[salsa::tracked(heap_size=get_size2::GetSize::get_heap_size)] + #[salsa::tracked(heap_size=get_size2::heap_size)] pub(crate) fn value_type(self, db: &'db dyn Db) -> Type<'db> { let scope = self.rhs_scope(db); let module = parsed_module(db, scope.file(db)).load(db); diff --git a/crates/ty_python_semantic/src/types/class.rs b/crates/ty_python_semantic/src/types/class.rs index cf9e7ff331..5e3bbc7029 100644 --- a/crates/ty_python_semantic/src/types/class.rs +++ b/crates/ty_python_semantic/src/types/class.rs @@ -1150,7 +1150,7 @@ impl<'db> ClassLiteral<'db> { self.pep695_generic_context(db).is_some() } - #[salsa::tracked(cycle_fn=pep695_generic_context_cycle_recover, cycle_initial=pep695_generic_context_cycle_initial, heap_size=get_size2::GetSize::get_heap_size)] + #[salsa::tracked(cycle_fn=pep695_generic_context_cycle_recover, cycle_initial=pep695_generic_context_cycle_initial, heap_size=get_size2::heap_size)] pub(crate) fn pep695_generic_context(self, db: &'db dyn Db) -> Option> { let scope = self.body_scope(db); let parsed = parsed_module(db, scope.file(db)).load(db); @@ -1260,7 +1260,7 @@ impl<'db> ClassLiteral<'db> { /// /// Were this not a salsa query, then the calling query /// would depend on the class's AST and rerun for every change in that file. - #[salsa::tracked(returns(deref), cycle_fn=explicit_bases_cycle_recover, cycle_initial=explicit_bases_cycle_initial, heap_size=get_size2::GetSize::get_heap_size)] + #[salsa::tracked(returns(deref), cycle_fn=explicit_bases_cycle_recover, cycle_initial=explicit_bases_cycle_initial, heap_size=get_size2::heap_size)] pub(super) fn explicit_bases(self, db: &'db dyn Db) -> Box<[Type<'db>]> { tracing::trace!("ClassLiteral::explicit_bases_query: {}", self.name(db)); @@ -1336,7 +1336,7 @@ impl<'db> ClassLiteral<'db> { } /// Return the types of the decorators on this class - #[salsa::tracked(returns(deref), heap_size=get_size2::GetSize::get_heap_size)] + #[salsa::tracked(returns(deref), heap_size=get_size2::heap_size)] fn decorators(self, db: &'db dyn Db) -> Box<[Type<'db>]> { tracing::trace!("ClassLiteral::decorators: {}", self.name(db)); @@ -1385,7 +1385,7 @@ impl<'db> ClassLiteral<'db> { /// attribute on a class at runtime. /// /// [method resolution order]: https://docs.python.org/3/glossary.html#term-method-resolution-order - #[salsa::tracked(returns(as_ref), cycle_fn=try_mro_cycle_recover, cycle_initial=try_mro_cycle_initial, heap_size=get_size2::GetSize::get_heap_size)] + #[salsa::tracked(returns(as_ref), cycle_fn=try_mro_cycle_recover, cycle_initial=try_mro_cycle_initial, heap_size=get_size2::heap_size)] pub(super) fn try_mro( self, db: &'db dyn Db, @@ -1465,7 +1465,7 @@ impl<'db> ClassLiteral<'db> { #[salsa::tracked( cycle_fn=try_metaclass_cycle_recover, cycle_initial=try_metaclass_cycle_initial, - heap_size=get_size2::GetSize::get_heap_size, + heap_size=get_size2::heap_size, )] pub(super) fn try_metaclass( self, @@ -2577,7 +2577,7 @@ impl<'db> ClassLiteral<'db> { /// /// A class definition like this will fail at runtime, /// but we must be resilient to it or we could panic. - #[salsa::tracked(cycle_fn=inheritance_cycle_recover, cycle_initial=inheritance_cycle_initial, heap_size=get_size2::GetSize::get_heap_size)] + #[salsa::tracked(cycle_fn=inheritance_cycle_recover, cycle_initial=inheritance_cycle_initial, heap_size=get_size2::heap_size)] pub(super) fn inheritance_cycle(self, db: &'db dyn Db) -> Option { /// Return `true` if the class is cyclically defined. /// diff --git a/crates/ty_python_semantic/src/types/enums.rs b/crates/ty_python_semantic/src/types/enums.rs index 2195e73a92..cdc01e479d 100644 --- a/crates/ty_python_semantic/src/types/enums.rs +++ b/crates/ty_python_semantic/src/types/enums.rs @@ -53,7 +53,7 @@ fn enum_metadata_cycle_initial(_db: &dyn Db, _class: ClassLiteral<'_>) -> Option /// List all members of an enum. #[allow(clippy::ref_option, clippy::unnecessary_wraps)] -#[salsa::tracked(returns(as_ref), cycle_fn=enum_metadata_cycle_recover, cycle_initial=enum_metadata_cycle_initial, heap_size=get_size2::GetSize::get_heap_size)] +#[salsa::tracked(returns(as_ref), cycle_fn=enum_metadata_cycle_recover, cycle_initial=enum_metadata_cycle_initial, heap_size=get_size2::heap_size)] pub(crate) fn enum_metadata<'db>( db: &'db dyn Db, class: ClassLiteral<'db>, diff --git a/crates/ty_python_semantic/src/types/function.rs b/crates/ty_python_semantic/src/types/function.rs index 2b1c71ef05..04e75976fc 100644 --- a/crates/ty_python_semantic/src/types/function.rs +++ b/crates/ty_python_semantic/src/types/function.rs @@ -499,7 +499,7 @@ impl<'db> FunctionLiteral<'db> { self.last_definition(db).spans(db) } - #[salsa::tracked(returns(ref), heap_size=get_size2::GetSize::get_heap_size)] + #[salsa::tracked(returns(ref), heap_size=get_size2::heap_size)] fn overloads_and_implementation( self, db: &'db dyn Db, @@ -790,7 +790,7 @@ impl<'db> FunctionType<'db> { /// /// Were this not a salsa query, then the calling query /// would depend on the function's AST and rerun for every change in that file. - #[salsa::tracked(returns(ref), cycle_fn=signature_cycle_recover, cycle_initial=signature_cycle_initial, heap_size=get_size2::GetSize::get_heap_size)] + #[salsa::tracked(returns(ref), cycle_fn=signature_cycle_recover, cycle_initial=signature_cycle_initial, heap_size=get_size2::heap_size)] pub(crate) fn signature(self, db: &'db dyn Db) -> CallableSignature<'db> { self.literal(db).signature(db, self.type_mappings(db)) } diff --git a/crates/ty_python_semantic/src/types/infer.rs b/crates/ty_python_semantic/src/types/infer.rs index 9f3b634e3c..5eed599ad5 100644 --- a/crates/ty_python_semantic/src/types/infer.rs +++ b/crates/ty_python_semantic/src/types/infer.rs @@ -131,7 +131,7 @@ use crate::{Db, FxOrderSet, Program}; /// Infer all types for a [`ScopeId`], including all definitions and expressions in that scope. /// Use when checking a scope, or needing to provide a type for an arbitrary expression in the /// scope. -#[salsa::tracked(returns(ref), cycle_fn=scope_cycle_recover, cycle_initial=scope_cycle_initial, heap_size=get_size2::GetSize::get_heap_size)] +#[salsa::tracked(returns(ref), cycle_fn=scope_cycle_recover, cycle_initial=scope_cycle_initial, heap_size=get_size2::heap_size)] pub(crate) fn infer_scope_types<'db>(db: &'db dyn Db, scope: ScopeId<'db>) -> ScopeInference<'db> { let file = scope.file(db); let _span = tracing::trace_span!("infer_scope_types", scope=?scope.as_id(), ?file).entered(); @@ -160,7 +160,7 @@ fn scope_cycle_initial<'db>(_db: &'db dyn Db, scope: ScopeId<'db>) -> ScopeInfer /// Infer all types for a [`Definition`] (including sub-expressions). /// Use when resolving a place use or public type of a place. -#[salsa::tracked(returns(ref), cycle_fn=definition_cycle_recover, cycle_initial=definition_cycle_initial, heap_size=get_size2::GetSize::get_heap_size)] +#[salsa::tracked(returns(ref), cycle_fn=definition_cycle_recover, cycle_initial=definition_cycle_initial, heap_size=get_size2::heap_size)] pub(crate) fn infer_definition_types<'db>( db: &'db dyn Db, definition: Definition<'db>, @@ -200,7 +200,7 @@ fn definition_cycle_initial<'db>( /// /// Deferred expressions are type expressions (annotations, base classes, aliases...) in a stub /// file, or in a file with `from __future__ import annotations`, or stringified annotations. -#[salsa::tracked(returns(ref), cycle_fn=deferred_cycle_recover, cycle_initial=deferred_cycle_initial, heap_size=get_size2::GetSize::get_heap_size)] +#[salsa::tracked(returns(ref), cycle_fn=deferred_cycle_recover, cycle_initial=deferred_cycle_initial, heap_size=get_size2::heap_size)] pub(crate) fn infer_deferred_types<'db>( db: &'db dyn Db, definition: Definition<'db>, @@ -241,7 +241,7 @@ fn deferred_cycle_initial<'db>( /// Use rarely; only for cases where we'd otherwise risk double-inferring an expression: RHS of an /// assignment, which might be unpacking/multi-target and thus part of multiple definitions, or a /// type narrowing guard expression (e.g. if statement test node). -#[salsa::tracked(returns(ref), cycle_fn=expression_cycle_recover, cycle_initial=expression_cycle_initial, heap_size=get_size2::GetSize::get_heap_size)] +#[salsa::tracked(returns(ref), cycle_fn=expression_cycle_recover, cycle_initial=expression_cycle_initial, heap_size=get_size2::heap_size)] pub(crate) fn infer_expression_types<'db>( db: &'db dyn Db, expression: Expression<'db>, @@ -299,7 +299,7 @@ pub(super) fn infer_same_file_expression_type<'db>( /// /// Use [`infer_same_file_expression_type`] if it is guaranteed that `expression` is in the same /// to avoid unnecessary salsa ingredients. This is normally the case inside the `TypeInferenceBuilder`. -#[salsa::tracked(cycle_fn=single_expression_cycle_recover, cycle_initial=single_expression_cycle_initial, heap_size=get_size2::GetSize::get_heap_size)] +#[salsa::tracked(cycle_fn=single_expression_cycle_recover, cycle_initial=single_expression_cycle_initial, heap_size=get_size2::heap_size)] pub(crate) fn infer_expression_type<'db>( db: &'db dyn Db, expression: Expression<'db>, @@ -333,7 +333,7 @@ fn single_expression_cycle_initial<'db>( /// involved in an unpacking operation. It returns a result-like object that can be used to get the /// type of the variables involved in this unpacking along with any violations that are detected /// during this unpacking. -#[salsa::tracked(returns(ref), cycle_fn=unpack_cycle_recover, cycle_initial=unpack_cycle_initial, heap_size=get_size2::GetSize::get_heap_size)] +#[salsa::tracked(returns(ref), cycle_fn=unpack_cycle_recover, cycle_initial=unpack_cycle_initial, heap_size=get_size2::heap_size)] pub(super) fn infer_unpack_types<'db>(db: &'db dyn Db, unpack: Unpack<'db>) -> UnpackResult<'db> { let file = unpack.file(db); let module = parsed_module(db, file).load(db); diff --git a/crates/ty_python_semantic/src/types/narrow.rs b/crates/ty_python_semantic/src/types/narrow.rs index 24be9f1e88..be02679fe7 100644 --- a/crates/ty_python_semantic/src/types/narrow.rs +++ b/crates/ty_python_semantic/src/types/narrow.rs @@ -72,7 +72,7 @@ pub(crate) fn infer_narrowing_constraint<'db>( } } -#[salsa::tracked(returns(as_ref), heap_size=get_size2::GetSize::get_heap_size)] +#[salsa::tracked(returns(as_ref), heap_size=get_size2::heap_size)] fn all_narrowing_constraints_for_pattern<'db>( db: &'db dyn Db, pattern: PatternPredicate<'db>, @@ -85,7 +85,7 @@ fn all_narrowing_constraints_for_pattern<'db>( returns(as_ref), cycle_fn=constraints_for_expression_cycle_recover, cycle_initial=constraints_for_expression_cycle_initial, - heap_size=get_size2::GetSize::get_heap_size, + heap_size=get_size2::heap_size, )] fn all_narrowing_constraints_for_expression<'db>( db: &'db dyn Db, @@ -100,7 +100,7 @@ fn all_narrowing_constraints_for_expression<'db>( returns(as_ref), cycle_fn=negative_constraints_for_expression_cycle_recover, cycle_initial=negative_constraints_for_expression_cycle_initial, - heap_size=get_size2::GetSize::get_heap_size, + heap_size=get_size2::heap_size, )] fn all_negative_narrowing_constraints_for_expression<'db>( db: &'db dyn Db, @@ -111,7 +111,7 @@ fn all_negative_narrowing_constraints_for_expression<'db>( .finish() } -#[salsa::tracked(returns(as_ref), heap_size=get_size2::GetSize::get_heap_size)] +#[salsa::tracked(returns(as_ref), heap_size=get_size2::heap_size)] fn all_negative_narrowing_constraints_for_pattern<'db>( db: &'db dyn Db, pattern: PatternPredicate<'db>, diff --git a/crates/ty_python_semantic/src/types/property_tests/type_generation.rs b/crates/ty_python_semantic/src/types/property_tests/type_generation.rs index 59c9a449b7..d974a94c54 100644 --- a/crates/ty_python_semantic/src/types/property_tests/type_generation.rs +++ b/crates/ty_python_semantic/src/types/property_tests/type_generation.rs @@ -115,7 +115,7 @@ enum ParamKind { KeywordVariadic, } -#[salsa::tracked(heap_size=get_size2::GetSize::get_heap_size)] +#[salsa::tracked(heap_size=get_size2::heap_size)] fn create_bound_method<'db>( db: &'db dyn Db, function: Type<'db>, diff --git a/crates/ty_python_semantic/src/types/protocol_class.rs b/crates/ty_python_semantic/src/types/protocol_class.rs index 4b01ce1670..845a3b8f47 100644 --- a/crates/ty_python_semantic/src/types/protocol_class.rs +++ b/crates/ty_python_semantic/src/types/protocol_class.rs @@ -453,7 +453,7 @@ enum BoundOnClass { } /// Inner Salsa query for [`ProtocolClassLiteral::interface`]. -#[salsa::tracked(cycle_fn=proto_interface_cycle_recover, cycle_initial=proto_interface_cycle_initial, heap_size=get_size2::GetSize::get_heap_size)] +#[salsa::tracked(cycle_fn=proto_interface_cycle_recover, cycle_initial=proto_interface_cycle_initial, heap_size=get_size2::heap_size)] fn cached_protocol_interface<'db>( db: &'db dyn Db, class: ClassLiteral<'db>,