Skip to content
Merged
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
6 changes: 3 additions & 3 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ rayon = { version = "1.10.0" }
regex = { version = "1.10.2" }
rustc-hash = { version = "2.0.0" }
# When updating salsa, make sure to also update the revision in `fuzz/Cargo.toml`
salsa = { git = "https://github.com/salsa-rs/salsa.git", rev = "095d8b2b8115c3cf8bf31914dd9ea74648bb7cf9" }
salsa = { git = "https://github.com/salsa-rs/salsa.git", rev = "d758691ba17ee1a60c5356ea90888d529e1782ad" }
schemars = { version = "0.8.16" }
seahash = { version = "4.1.0" }
serde = { version = "1.0.197", features = ["derive"] }
Expand Down
3 changes: 1 addition & 2 deletions crates/red_knot_project/src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,8 @@ impl ProjectDatabase {
self.with_db(|db| db.project().check(db))
}

#[tracing::instrument(level = "debug", skip(self))]
pub fn check_file(&self, file: File) -> Result<Vec<Box<dyn OldDiagnosticTrait>>, Cancelled> {
let _span = tracing::debug_span!("check_file", file=%file.path(self)).entered();

self.with_db(|db| self.project().check_file(db, file))
}

Expand Down
5 changes: 3 additions & 2 deletions crates/red_knot_project/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,8 @@ impl Project {
let project_span = project_span.clone();

scope.spawn(move |_| {
let check_file_span = tracing::debug_span!(parent: &project_span, "check_file", file=%file.path(&db));
let check_file_span =
tracing::debug_span!(parent: &project_span, "check_file", ?file);
let _entered = check_file_span.entered();

let file_diagnostics = check_file_impl(&db, file);
Expand Down Expand Up @@ -325,7 +326,7 @@ impl Project {
self.files(db).contains(&file)
}

#[tracing::instrument(level = "debug", skip(db))]
#[tracing::instrument(level = "debug", skip(self, db))]
pub fn remove_file(self, db: &mut dyn Db, file: File) {
tracing::debug!(
"Removing file `{}` from project `{}`",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ impl<'db> Iterator for PthFileIterator<'db> {
/// A thin wrapper around `ModuleName` to make it a Salsa ingredient.
///
/// This is needed because Salsa requires that all query arguments are salsa ingredients.
#[salsa::interned]
#[salsa::interned(debug)]
struct ModuleNameIngredient<'db> {
#[return_ref]
pub(super) name: ModuleName,
Expand Down
10 changes: 4 additions & 6 deletions crates/red_knot_python_semantic/src/semantic_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ type SymbolMap = hashbrown::HashMap<ScopedSymbolId, (), FxBuildHasher>;
/// Prefer using [`symbol_table`] when working with symbols from a single scope.
#[salsa::tracked(return_ref, no_eq)]
pub(crate) fn semantic_index(db: &dyn Db, file: File) -> SemanticIndex<'_> {
let _span = tracing::trace_span!("semantic_index", file = %file.path(db)).entered();
let _span = tracing::trace_span!("semantic_index", ?file).entered();

let parsed = parsed_module(db.upcast(), file);

Expand All @@ -60,8 +60,7 @@ pub(crate) fn semantic_index(db: &dyn Db, file: File) -> SemanticIndex<'_> {
#[salsa::tracked]
pub(crate) fn symbol_table<'db>(db: &'db dyn Db, scope: ScopeId<'db>) -> Arc<SymbolTable> {
let file = scope.file(db);
let _span =
tracing::trace_span!("symbol_table", scope=?scope.as_id(), file=%file.path(db)).entered();
let _span = tracing::trace_span!("symbol_table", scope=?scope.as_id(), ?file).entered();
let index = semantic_index(db, file);

index.symbol_table(scope.file_scope_id(db))
Expand Down Expand Up @@ -91,8 +90,7 @@ pub(crate) fn imported_modules<'db>(db: &'db dyn Db, file: File) -> Arc<FxHashSe
#[salsa::tracked]
pub(crate) fn use_def_map<'db>(db: &'db dyn Db, scope: ScopeId<'db>) -> Arc<UseDefMap<'db>> {
let file = scope.file(db);
let _span =
tracing::trace_span!("use_def_map", scope=?scope.as_id(), file=%file.path(db)).entered();
let _span = tracing::trace_span!("use_def_map", scope=?scope.as_id(), ?file).entered();
let index = semantic_index(db, file);

index.use_def_map(scope.file_scope_id(db))
Expand Down Expand Up @@ -120,7 +118,7 @@ pub(crate) fn attribute_assignments<'db>(
/// Returns the module global scope of `file`.
#[salsa::tracked]
pub(crate) fn global_scope(db: &dyn Db, file: File) -> ScopeId<'_> {
let _span = tracing::trace_span!("global_scope", file = %file.path(db)).entered();
let _span = tracing::trace_span!("global_scope", ?file).entered();

FileScopeId::global().to_scope_id(db, file)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use crate::Db;
/// * a return type of a cross-module query
/// * a field of a type that is a return type of a cross-module query
/// * an argument of a cross-module query
#[salsa::tracked]
#[salsa::tracked(debug)]
pub struct Definition<'db> {
/// The file in which the definition occurs.
pub(crate) file: File,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub(crate) enum ExpressionKind {
/// * a return type of a cross-module query
/// * a field of a type that is a return type of a cross-module query
/// * an argument of a cross-module query
#[salsa::tracked]
#[salsa::tracked(debug)]
pub(crate) struct Expression<'db> {
/// The file in which the expression occurs.
pub(crate) file: File,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ pub(crate) enum PatternPredicateKind<'db> {
Unsupported,
}

#[salsa::tracked]
#[salsa::tracked(debug)]
pub(crate) struct PatternPredicate<'db> {
pub(crate) file: File,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ impl From<FileSymbolId> for ScopedSymbolId {
pub struct ScopedSymbolId;

/// A cross-module identifier of a scope that can be used as a salsa query parameter.
#[salsa::tracked]
#[salsa::tracked(debug)]
pub struct ScopeId<'db> {
pub file: File,

Expand Down
26 changes: 13 additions & 13 deletions crates/red_knot_python_semantic/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ mod property_tests;

#[salsa::tracked(return_ref)]
pub fn check_types(db: &dyn Db, file: File) -> TypeCheckDiagnostics {
let _span = tracing::trace_span!("check_types", file=?file.path(db)).entered();
let _span = tracing::trace_span!("check_types", ?file).entered();

tracing::debug!("Checking file '{path}'", path = file.path(db));

Expand Down Expand Up @@ -3605,7 +3605,7 @@ impl<'db> InvalidTypeExpression<'db> {
/// This must be a tracked struct, not an interned one, because typevar equivalence is by identity,
/// not by value. Two typevars that have the same name, bound/constraints, and default, are still
/// different typevars: if used in the same scope, they may be bound to different types.
#[salsa::tracked]
#[salsa::tracked(debug)]
pub struct TypeVarInstance<'db> {
/// The name of this TypeVar (e.g. `T`)
#[return_ref]
Expand Down Expand Up @@ -4308,7 +4308,7 @@ impl From<bool> for Truthiness {
}
}

#[salsa::interned]
#[salsa::interned(debug)]
pub struct FunctionType<'db> {
/// name of the function at definition
#[return_ref]
Expand Down Expand Up @@ -4538,7 +4538,7 @@ impl KnownFunction {
/// on an instance of a class. For example, the expression `Path("a.txt").touch` creates
/// a bound method object that represents the `Path.touch` method which is bound to the
/// instance `Path("a.txt")`.
#[salsa::tracked]
#[salsa::tracked(debug)]
pub struct BoundMethodType<'db> {
/// The function that is being bound. Corresponds to the `__func__` attribute on a
/// bound method object
Expand All @@ -4550,7 +4550,7 @@ pub struct BoundMethodType<'db> {

/// This type represents a general callable type that are used to represent `typing.Callable`
/// and `lambda` expressions.
#[salsa::interned]
#[salsa::interned(debug)]
pub struct GeneralCallableType<'db> {
#[return_ref]
signature: Signature<'db>,
Expand Down Expand Up @@ -4734,7 +4734,7 @@ enum ParameterExpectation {
TypeExpression,
}

#[salsa::interned]
#[salsa::interned(debug)]
pub struct ModuleLiteralType<'db> {
/// The file in which this module was imported.
///
Expand Down Expand Up @@ -4783,7 +4783,7 @@ impl<'db> ModuleLiteralType<'db> {
}
}

#[salsa::interned]
#[salsa::interned(debug)]
pub struct TypeAliasType<'db> {
#[return_ref]
pub name: ast::name::Name,
Expand Down Expand Up @@ -4811,7 +4811,7 @@ pub(super) struct MetaclassCandidate<'db> {
explicit_metaclass_of: Class<'db>,
}

#[salsa::interned]
#[salsa::interned(debug)]
pub struct UnionType<'db> {
/// The union type includes values in any of these types.
#[return_ref]
Expand Down Expand Up @@ -5022,7 +5022,7 @@ impl<'db> UnionType<'db> {
}
}

#[salsa::interned]
#[salsa::interned(debug)]
pub struct IntersectionType<'db> {
/// The intersection type includes only values in all of these types.
#[return_ref]
Expand Down Expand Up @@ -5253,7 +5253,7 @@ impl<'db> IntersectionType<'db> {
}
}

#[salsa::interned]
#[salsa::interned(debug)]
pub struct StringLiteralType<'db> {
#[return_ref]
value: Box<str>,
Expand All @@ -5266,7 +5266,7 @@ impl<'db> StringLiteralType<'db> {
}
}

#[salsa::interned]
#[salsa::interned(debug)]
pub struct BytesLiteralType<'db> {
#[return_ref]
value: Box<[u8]>,
Expand All @@ -5278,7 +5278,7 @@ impl<'db> BytesLiteralType<'db> {
}
}

#[salsa::interned]
#[salsa::interned(debug)]
pub struct SliceLiteralType<'db> {
start: Option<i32>,
stop: Option<i32>,
Expand All @@ -5290,7 +5290,7 @@ impl SliceLiteralType<'_> {
(self.start(db), self.stop(db), self.step(db))
}
}
#[salsa::interned]
#[salsa::interned(debug)]
pub struct TupleType<'db> {
#[return_ref]
elements: Box<[Type<'db>]>,
Expand Down
2 changes: 1 addition & 1 deletion crates/red_knot_python_semantic/src/types/class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use super::{
///
/// Does not in itself represent a type,
/// but is used as the inner data for several structs that *do* represent types.
#[salsa::interned]
#[salsa::interned(debug)]
pub struct Class<'db> {
/// Name of the class at definition
#[return_ref]
Expand Down
13 changes: 5 additions & 8 deletions crates/red_knot_python_semantic/src/types/infer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,7 @@ use super::{CallDunderError, ParameterExpectation, ParameterExpectations};
#[salsa::tracked(return_ref, cycle_fn=scope_cycle_recover, cycle_initial=scope_cycle_initial)]
pub(crate) fn infer_scope_types<'db>(db: &'db dyn Db, scope: ScopeId<'db>) -> TypeInference<'db> {
let file = scope.file(db);
let _span =
tracing::trace_span!("infer_scope_types", scope=?scope.as_id(), file=%file.path(db))
.entered();
let _span = tracing::trace_span!("infer_scope_types", scope=?scope.as_id(), ?file).entered();

// Using the index here is fine because the code below depends on the AST anyway.
// The isolation of the query is by the return inferred types.
Expand Down Expand Up @@ -146,7 +144,7 @@ pub(crate) fn infer_definition_types<'db>(
let _span = tracing::trace_span!(
"infer_definition_types",
range = ?definition.kind(db).target_range(),
file = %file.path(db)
?file
)
.entered();

Expand Down Expand Up @@ -185,7 +183,7 @@ pub(crate) fn infer_deferred_types<'db>(
"infer_deferred_types",
definition = ?definition.as_id(),
range = ?definition.kind(db).target_range(),
file = %file.path(db)
?file
)
.entered();

Expand Down Expand Up @@ -221,7 +219,7 @@ pub(crate) fn infer_expression_types<'db>(
"infer_expression_types",
expression = ?expression.as_id(),
range = ?expression.node_ref(db).range(),
file = %file.path(db)
?file
)
.entered();

Expand Down Expand Up @@ -302,8 +300,7 @@ fn single_expression_cycle_initial<'db>(
pub(super) fn infer_unpack_types<'db>(db: &'db dyn Db, unpack: Unpack<'db>) -> UnpackResult<'db> {
let file = unpack.file(db);
let _span =
tracing::trace_span!("infer_unpack_types", range=?unpack.range(db), file=%file.path(db))
.entered();
tracing::trace_span!("infer_unpack_types", range=?unpack.range(db), ?file).entered();

let mut unpacker = Unpacker::new(db, unpack.scope(db));
unpacker.unpack(unpack.target(db), unpack.value(db));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ pub(crate) fn parse_string_annotation(
let file = context.file();
let db = context.db();

let _span = tracing::trace_span!("parse_string_annotation", string=?string_expr.range(), file=%file.path(db)).entered();
let _span = tracing::trace_span!("parse_string_annotation", string=?string_expr.range(), ?file)
.entered();

let source = source_text(db.upcast(), file);

Expand Down
2 changes: 1 addition & 1 deletion crates/red_knot_python_semantic/src/unpack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use crate::Db;
/// * a return type of a cross-module query
/// * a field of a type that is a return type of a cross-module query
/// * an argument of a cross-module query
#[salsa::tracked]
#[salsa::tracked(debug)]
pub(crate) struct Unpack<'db> {
pub(crate) file: File,

Expand Down
Loading
Loading