Skip to content

Commit e7d216e

Browse files
committed
[internal]: Upgrade salsa
1 parent dbdb46d commit e7d216e

File tree

21 files changed

+70
-56
lines changed

21 files changed

+70
-56
lines changed

Cargo.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ rayon = { version = "1.10.0" }
123123
regex = { version = "1.10.2" }
124124
rustc-hash = { version = "2.0.0" }
125125
# When updating salsa, make sure to also update the revision in `fuzz/Cargo.toml`
126-
salsa = { git = "https://github.com/salsa-rs/salsa.git", rev = "095d8b2b8115c3cf8bf31914dd9ea74648bb7cf9" }
126+
salsa = { git = "https://github.com/salsa-rs/salsa.git", rev = "d758691ba17ee1a60c5356ea90888d529e1782ad" }
127127
schemars = { version = "0.8.16" }
128128
seahash = { version = "4.1.0" }
129129
serde = { version = "1.0.197", features = ["derive"] }

crates/red_knot_project/src/db.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,8 @@ impl ProjectDatabase {
5959
self.with_db(|db| db.project().check(db))
6060
}
6161

62+
#[tracing::instrument(level = "debug", skip(self))]
6263
pub fn check_file(&self, file: File) -> Result<Vec<Box<dyn OldDiagnosticTrait>>, Cancelled> {
63-
let _span = tracing::debug_span!("check_file", file=%file.path(self)).entered();
64-
6564
self.with_db(|db| self.project().check_file(db, file))
6665
}
6766

crates/red_knot_project/src/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,8 @@ impl Project {
195195
let project_span = project_span.clone();
196196

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

201202
let file_diagnostics = check_file_impl(&db, file);
@@ -325,7 +326,7 @@ impl Project {
325326
self.files(db).contains(&file)
326327
}
327328

328-
#[tracing::instrument(level = "debug", skip(db))]
329+
#[tracing::instrument(level = "debug", skip(self, db))]
329330
pub fn remove_file(self, db: &mut dyn Db, file: File) {
330331
tracing::debug!(
331332
"Removing file `{}` from project `{}`",

crates/red_knot_python_semantic/src/module_resolver/resolver.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ impl<'db> Iterator for PthFileIterator<'db> {
534534
/// A thin wrapper around `ModuleName` to make it a Salsa ingredient.
535535
///
536536
/// This is needed because Salsa requires that all query arguments are salsa ingredients.
537-
#[salsa::interned]
537+
#[salsa::interned(debug)]
538538
struct ModuleNameIngredient<'db> {
539539
#[return_ref]
540540
pub(super) name: ModuleName,

crates/red_knot_python_semantic/src/semantic_index.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ type SymbolMap = hashbrown::HashMap<ScopedSymbolId, (), FxBuildHasher>;
4545
/// Prefer using [`symbol_table`] when working with symbols from a single scope.
4646
#[salsa::tracked(return_ref, no_eq)]
4747
pub(crate) fn semantic_index(db: &dyn Db, file: File) -> SemanticIndex<'_> {
48-
let _span = tracing::trace_span!("semantic_index", file = %file.path(db)).entered();
48+
let _span = tracing::trace_span!("semantic_index", ?file).entered();
4949

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

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

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

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

125123
FileScopeId::global().to_scope_id(db, file)
126124
}

crates/red_knot_python_semantic/src/semantic_index/definition.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use crate::Db;
2222
/// * a return type of a cross-module query
2323
/// * a field of a type that is a return type of a cross-module query
2424
/// * an argument of a cross-module query
25-
#[salsa::tracked]
25+
#[salsa::tracked(debug)]
2626
pub struct Definition<'db> {
2727
/// The file in which the definition occurs.
2828
pub(crate) file: File,

crates/red_knot_python_semantic/src/semantic_index/expression.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ pub(crate) enum ExpressionKind {
3030
/// * a return type of a cross-module query
3131
/// * a field of a type that is a return type of a cross-module query
3232
/// * an argument of a cross-module query
33-
#[salsa::tracked]
33+
#[salsa::tracked(debug)]
3434
pub(crate) struct Expression<'db> {
3535
/// The file in which the expression occurs.
3636
pub(crate) file: File,

crates/red_knot_python_semantic/src/semantic_index/predicate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ pub(crate) enum PatternPredicateKind<'db> {
6363
Unsupported,
6464
}
6565

66-
#[salsa::tracked]
66+
#[salsa::tracked(debug)]
6767
pub(crate) struct PatternPredicate<'db> {
6868
pub(crate) file: File,
6969

crates/red_knot_python_semantic/src/semantic_index/symbol.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ impl From<FileSymbolId> for ScopedSymbolId {
100100
pub struct ScopedSymbolId;
101101

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

crates/red_knot_python_semantic/src/types.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ mod property_tests;
6262

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

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

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

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

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

4737-
#[salsa::interned]
4737+
#[salsa::interned(debug)]
47384738
pub struct ModuleLiteralType<'db> {
47394739
/// The file in which this module was imported.
47404740
///
@@ -4783,7 +4783,7 @@ impl<'db> ModuleLiteralType<'db> {
47834783
}
47844784
}
47854785

4786-
#[salsa::interned]
4786+
#[salsa::interned(debug)]
47874787
pub struct TypeAliasType<'db> {
47884788
#[return_ref]
47894789
pub name: ast::name::Name,
@@ -4811,7 +4811,7 @@ pub(super) struct MetaclassCandidate<'db> {
48114811
explicit_metaclass_of: Class<'db>,
48124812
}
48134813

4814-
#[salsa::interned]
4814+
#[salsa::interned(debug)]
48154815
pub struct UnionType<'db> {
48164816
/// The union type includes values in any of these types.
48174817
#[return_ref]
@@ -5022,7 +5022,7 @@ impl<'db> UnionType<'db> {
50225022
}
50235023
}
50245024

5025-
#[salsa::interned]
5025+
#[salsa::interned(debug)]
50265026
pub struct IntersectionType<'db> {
50275027
/// The intersection type includes only values in all of these types.
50285028
#[return_ref]
@@ -5253,7 +5253,7 @@ impl<'db> IntersectionType<'db> {
52535253
}
52545254
}
52555255

5256-
#[salsa::interned]
5256+
#[salsa::interned(debug)]
52575257
pub struct StringLiteralType<'db> {
52585258
#[return_ref]
52595259
value: Box<str>,
@@ -5266,7 +5266,7 @@ impl<'db> StringLiteralType<'db> {
52665266
}
52675267
}
52685268

5269-
#[salsa::interned]
5269+
#[salsa::interned(debug)]
52705270
pub struct BytesLiteralType<'db> {
52715271
#[return_ref]
52725272
value: Box<[u8]>,
@@ -5278,7 +5278,7 @@ impl<'db> BytesLiteralType<'db> {
52785278
}
52795279
}
52805280

5281-
#[salsa::interned]
5281+
#[salsa::interned(debug)]
52825282
pub struct SliceLiteralType<'db> {
52835283
start: Option<i32>,
52845284
stop: Option<i32>,
@@ -5290,7 +5290,7 @@ impl SliceLiteralType<'_> {
52905290
(self.start(db), self.stop(db), self.step(db))
52915291
}
52925292
}
5293-
#[salsa::interned]
5293+
#[salsa::interned(debug)]
52945294
pub struct TupleType<'db> {
52955295
#[return_ref]
52965296
elements: Box<[Type<'db>]>,

crates/red_knot_python_semantic/src/types/class.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ use super::{
3232
///
3333
/// Does not in itself represent a type,
3434
/// but is used as the inner data for several structs that *do* represent types.
35-
#[salsa::interned]
35+
#[salsa::interned(debug)]
3636
pub struct Class<'db> {
3737
/// Name of the class at definition
3838
#[return_ref]

crates/red_knot_python_semantic/src/types/infer.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,7 @@ use super::{CallDunderError, ParameterExpectation, ParameterExpectations};
111111
#[salsa::tracked(return_ref, cycle_fn=scope_cycle_recover, cycle_initial=scope_cycle_initial)]
112112
pub(crate) fn infer_scope_types<'db>(db: &'db dyn Db, scope: ScopeId<'db>) -> TypeInference<'db> {
113113
let file = scope.file(db);
114-
let _span =
115-
tracing::trace_span!("infer_scope_types", scope=?scope.as_id(), file=%file.path(db))
116-
.entered();
114+
let _span = tracing::trace_span!("infer_scope_types", scope=?scope.as_id(), ?file).entered();
117115

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

@@ -185,7 +183,7 @@ pub(crate) fn infer_deferred_types<'db>(
185183
"infer_deferred_types",
186184
definition = ?definition.as_id(),
187185
range = ?definition.kind(db).target_range(),
188-
file = %file.path(db)
186+
?file
189187
)
190188
.entered();
191189

@@ -221,7 +219,7 @@ pub(crate) fn infer_expression_types<'db>(
221219
"infer_expression_types",
222220
expression = ?expression.as_id(),
223221
range = ?expression.node_ref(db).range(),
224-
file = %file.path(db)
222+
?file
225223
)
226224
.entered();
227225

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

308305
let mut unpacker = Unpacker::new(db, unpack.scope(db));
309306
unpacker.unpack(unpack.target(db), unpack.value(db));

crates/red_knot_python_semantic/src/types/string_annotation.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,8 @@ pub(crate) fn parse_string_annotation(
134134
let file = context.file();
135135
let db = context.db();
136136

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

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

crates/red_knot_python_semantic/src/unpack.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use crate::Db;
2626
/// * a return type of a cross-module query
2727
/// * a field of a type that is a return type of a cross-module query
2828
/// * an argument of a cross-module query
29-
#[salsa::tracked]
29+
#[salsa::tracked(debug)]
3030
pub(crate) struct Unpack<'db> {
3131
pub(crate) file: File,
3232

0 commit comments

Comments
 (0)