Skip to content

Commit

Permalink
Mark node fields as tracked
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaReiser committed Feb 9, 2025
1 parent d34846b commit 5106cec
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub(crate) enum ConstraintNode<'db> {
}

/// Pattern kinds for which we support type narrowing and/or static visibility analysis.
#[derive(Debug, Clone, Hash, PartialEq)]
#[derive(Debug, Clone, Hash, PartialEq, salsa::Update)]
pub(crate) enum PatternConstraintKind<'db> {
Singleton(Singleton, Option<Expression<'db>>),
Value(Expression<'db>, Option<Expression<'db>>),
Expand All @@ -32,11 +32,8 @@ pub(crate) struct PatternConstraint<'db> {

pub(crate) file_scope: FileScopeId,

#[no_eq]
#[return_ref]
pub(crate) subject: Expression<'db>,

#[no_eq]
#[return_ref]
pub(crate) kind: PatternConstraintKind<'db>,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ pub struct Definition<'db> {

#[no_eq]
#[return_ref]
#[tracked]
pub(crate) kind: DefinitionKind<'db>,

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ pub(crate) struct Expression<'db> {
pub(crate) file_scope: FileScopeId,

/// The expression node.
#[no_eq]
#[return_ref]
#[tracked]
pub(crate) node_ref: AstNodeRef<ast::Expr>,

/// Should this expression be inferred as a normal expression or a type expression?
Expand Down
4 changes: 2 additions & 2 deletions crates/red_knot_python_semantic/src/types/narrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,10 @@ impl<'db> NarrowingConstraintsBuilder<'db> {

match pattern.kind(self.db) {
PatternConstraintKind::Singleton(singleton, _guard) => {
self.evaluate_match_pattern_singleton(*subject, *singleton)
self.evaluate_match_pattern_singleton(subject, *singleton)
}
PatternConstraintKind::Class(cls, _guard) => {
self.evaluate_match_pattern_class(*subject, *cls)
self.evaluate_match_pattern_class(subject, *cls)
}
// TODO: support more pattern kinds
PatternConstraintKind::Value(..) | PatternConstraintKind::Unsupported => None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,7 @@ impl<'db> VisibilityConstraints<'db> {
ConstraintNode::Pattern(inner) => match inner.kind(db) {
PatternConstraintKind::Value(value, guard) => {
let subject_expression = inner.subject(db);
let inference = infer_expression_types(db, *subject_expression);
let inference = infer_expression_types(db, subject_expression);
let scope = subject_expression.scope(db);
let subject_ty = inference.expression_type(
subject_expression
Expand Down
4 changes: 2 additions & 2 deletions crates/ruff_db/src/testing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub fn assert_function_query_was_not_run<Db, Q, QDb, I, R>(

db.attach(|_| {
if let Some(will_execute_event) = will_execute_event {
panic!("Expected query {query_name}({id}) not to have run but it did: {will_execute_event:?}");
panic!("Expected query {query_name}({id}) not to have run but it did: {will_execute_event:?}\n\n{events:#?}");
}
});
}
Expand Down Expand Up @@ -46,7 +46,7 @@ pub fn assert_const_function_query_was_not_run<Db, Q, QDb, R>(
db.attach(|_| {
if let Some(will_execute_event) = event {
panic!(
"Expected query {query_name}() not to have run but it did: {will_execute_event:?}"
"Expected query {query_name}() not to have run but it did: {will_execute_event:?}\n\n{events:#?}"
);
}
});
Expand Down
2 changes: 1 addition & 1 deletion fuzz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ ruff_python_formatter = { path = "../crates/ruff_python_formatter" }
ruff_text_size = { path = "../crates/ruff_text_size" }

libfuzzer-sys = { git = "https://github.com/rust-fuzz/libfuzzer", default-features = false }
salsa = { git = "https://github.com/ibraheemdev/salsa.git", rev = "22f742a53d9eafca80fe5a0a6b188b56243c741c" }
salsa = { git = "https://github.com/MichaReiser/salsa.git", rev = "c48a9df2ec58d816e0f602ee3fee3ef483b2f1d4" }
similar = { version = "2.5.0" }
tracing = { version = "0.1.40" }

Expand Down

0 comments on commit 5106cec

Please sign in to comment.