Skip to content

Commit

Permalink
Update salsa version
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaReiser committed Feb 9, 2025
1 parent ca7d2da commit d34846b
Show file tree
Hide file tree
Showing 11 changed files with 11 additions and 39 deletions.
3 changes: 3 additions & 0 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/ibraheemdev/salsa.git", rev = "22f742a53d9eafca80fe5a0a6b188b56243c741c" }
salsa = { git = "https://github.com/MichaReiser/salsa.git", rev = "c48a9df2ec58d816e0f602ee3fee3ef483b2f1d4" }
schemars = { version = "0.8.16" }
seahash = { version = "4.1.0" }
serde = { version = "1.0.197", features = ["derive"] }
Expand Down
14 changes: 0 additions & 14 deletions crates/red_knot_python_semantic/src/ast_node_ref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,20 +86,6 @@ unsafe impl<T> Send for AstNodeRef<T> where T: Send {}
#[allow(unsafe_code)]
unsafe impl<T> Sync for AstNodeRef<T> where T: Sync {}

#[allow(unsafe_code)]
unsafe impl<T> salsa::Update for AstNodeRef<T> {
unsafe fn maybe_update(old_pointer: *mut Self, new_value: Self) -> bool {
let old_node: &mut AstNodeRef<T> = unsafe { &mut *old_pointer };

if old_node._parsed == new_value._parsed {
false
} else {
*old_node = new_value;
true
}
}
}

#[cfg(test)]
mod tests {
use crate::ast_node_ref::AstNodeRef;
Expand Down
14 changes: 3 additions & 11 deletions crates/red_knot_python_semantic/src/semantic_index/ast_ids.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use crate::Db;
///
/// x = foo()
/// ```
#[derive(Debug)]
#[derive(Debug, salsa::Update)]
pub(crate) struct AstIds {
/// Maps expressions to their expression id.
expressions_map: FxHashMap<ExpressionNodeKey, ScopedExpressionId>,
Expand All @@ -49,15 +49,6 @@ fn ast_ids<'db>(db: &'db dyn Db, scope: ScopeId) -> &'db AstIds {
semantic_index(db, scope.file(db)).ast_ids(scope.file_scope_id(db))
}

// Always consider AstIds as changed.
#[allow(unsafe_code)]
unsafe impl salsa::Update for AstIds {
unsafe fn maybe_update(old_pointer: *mut Self, new_value: Self) -> bool {
*old_pointer = new_value;
true
}
}

/// Uniquely identifies a use of a name in a [`crate::semantic_index::symbol::FileScopeId`].
#[newtype_index]
pub struct ScopedUseId;
Expand All @@ -83,6 +74,7 @@ impl HasScopedUseId for ast::ExprRef<'_> {

/// Uniquely identifies an [`ast::Expr`] in a [`crate::semantic_index::symbol::FileScopeId`].
#[newtype_index]
#[derive(salsa::Update)]
pub struct ScopedExpressionId;

pub trait HasScopedExpressionId {
Expand Down Expand Up @@ -190,7 +182,7 @@ pub(crate) mod node_key {

use crate::node_key::NodeKey;

#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug, salsa::Update)]
pub(crate) struct ExpressionNodeKey(NodeKey);

impl From<ast::ExprRef<'_>> for ExpressionNodeKey {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ pub(crate) struct PatternConstraint<'db> {
#[return_ref]
pub(crate) kind: PatternConstraintKind<'db>,

#[no_eq]
count: countme::Count<PatternConstraint<'static>>,
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,7 @@ impl ExceptHandlerDefinitionKind {
}
}

#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug, salsa::Update)]
pub(crate) struct DefinitionNodeKey(NodeKey);

impl From<&ast::Alias> for DefinitionNodeKey {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,8 @@ pub(crate) struct Expression<'db> {
pub(crate) node_ref: AstNodeRef<ast::Expr>,

/// Should this expression be inferred as a normal expression or a type expression?
#[id]
pub(crate) kind: ExpressionKind,

#[no_eq]
count: countme::Count<Expression<'static>>,
}

Expand Down
3 changes: 2 additions & 1 deletion crates/red_knot_python_semantic/src/semantic_index/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ impl From<FileSymbolId> for ScopedSymbolId {

/// Symbol ID that uniquely identifies a symbol inside a [`Scope`].
#[newtype_index]
#[derive(salsa::Update)]
pub struct ScopedSymbolId;

/// A cross-module identifier of a scope that can be used as a salsa query parameter.
Expand All @@ -105,7 +106,6 @@ pub struct ScopeId<'db> {

pub file_scope_id: FileScopeId,

#[no_eq]
count: countme::Count<ScopeId<'static>>,
}

Expand Down Expand Up @@ -157,6 +157,7 @@ impl<'db> ScopeId<'db> {

/// ID that uniquely identifies a scope inside of a module.
#[newtype_index]
#[derive(salsa::Update)]
pub struct FileScopeId;

impl FileScopeId {
Expand Down
1 change: 1 addition & 0 deletions crates/red_knot_python_semantic/src/types/infer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6432,6 +6432,7 @@ mod tests {
assert_eq!(attr_ty.display(&db).to_string(), "Unknown | str | None");
db.take_salsa_events()
};

assert_function_query_was_not_run(
&db,
infer_expression_types,
Expand Down
1 change: 0 additions & 1 deletion crates/red_knot_python_semantic/src/unpack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ pub(crate) struct Unpack<'db> {
#[no_eq]
pub(crate) value: UnpackValue<'db>,

#[no_eq]
count: countme::Count<Unpack<'static>>,
}

Expand Down
7 changes: 0 additions & 7 deletions crates/ruff_db/src/parsed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,6 @@ impl PartialEq for ParsedModule {

impl Eq for ParsedModule {}

unsafe impl salsa::Update for ParsedModule {
unsafe fn maybe_update(old_pointer: *mut Self, new_value: Self) -> bool {
*old_pointer = new_value;
true
}
}

#[cfg(test)]
mod tests {
use crate::files::{system_path_to_file, vendored_path_to_file};
Expand Down

0 comments on commit d34846b

Please sign in to comment.