mirror of
https://github.com/salsa-rs/salsa.git
synced 2025-01-14 17:18:20 +00:00
generate a custom std::fmt::Debug
impl
This leads less representation information and in particular avoids serializing pointers.
This commit is contained in:
parent
d98485d3cb
commit
4f4d01958f
15 changed files with 195 additions and 227 deletions
|
@ -58,6 +58,7 @@ impl InputStruct {
|
|||
let from_id_impl = self.from_id_impl();
|
||||
let salsa_struct_in_db_impl = self.salsa_struct_in_db_impl();
|
||||
let as_debug_with_db_impl = self.as_debug_with_db_impl();
|
||||
let debug_impl = self.debug_impl();
|
||||
|
||||
Ok(quote! {
|
||||
#id_struct
|
||||
|
@ -67,6 +68,7 @@ impl InputStruct {
|
|||
#from_id_impl
|
||||
#as_debug_with_db_impl
|
||||
#salsa_struct_in_db_impl
|
||||
#debug_impl
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -68,6 +68,7 @@ impl InternedStruct {
|
|||
let named_fields_impl = self.inherent_impl_for_named_fields();
|
||||
let salsa_struct_in_db_impl = self.salsa_struct_in_db_impl();
|
||||
let as_debug_with_db_impl = self.as_debug_with_db_impl();
|
||||
let debug_impl = self.debug_impl();
|
||||
let update_impl = self.update_impl();
|
||||
|
||||
Ok(crate::debug::dump_tokens(
|
||||
|
@ -86,6 +87,7 @@ impl InternedStruct {
|
|||
#salsa_struct_in_db_impl
|
||||
#as_debug_with_db_impl
|
||||
#update_impl
|
||||
#debug_impl
|
||||
},
|
||||
))
|
||||
}
|
||||
|
|
|
@ -309,7 +309,7 @@ impl<A: AllowedOptions> SalsaStruct<A> {
|
|||
|
||||
parse_quote_spanned! { ident.span() =>
|
||||
#(#attrs)*
|
||||
#[derive(Copy, Clone, PartialEq, PartialOrd, Eq, Ord, Hash, Debug)]
|
||||
#[derive(Copy, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
|
||||
#visibility struct #ident(salsa::Id);
|
||||
}
|
||||
}
|
||||
|
@ -347,7 +347,7 @@ impl<A: AllowedOptions> SalsaStruct<A> {
|
|||
|
||||
Ok(parse_quote_spanned! { ident.span() =>
|
||||
#(#attrs)*
|
||||
#[derive(Copy, Clone, PartialEq, PartialOrd, Eq, Ord, Hash, Debug)]
|
||||
#[derive(Copy, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
|
||||
#visibility struct #ident #generics (
|
||||
*const salsa::#module::ValueStruct < #config_ident >,
|
||||
std::marker::PhantomData < & #lifetime salsa::#module::ValueStruct < #config_ident > >
|
||||
|
@ -465,6 +465,27 @@ impl<A: AllowedOptions> SalsaStruct<A> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Generate `impl salsa::DebugWithDb for Foo`, but only if this is an id struct.
|
||||
pub(crate) fn debug_impl(&self) -> syn::ItemImpl {
|
||||
let ident = self.the_ident();
|
||||
let (impl_generics, type_generics, where_clause) =
|
||||
self.struct_item.generics.split_for_impl();
|
||||
let ident_string = ident.to_string();
|
||||
|
||||
// `use ::salsa::debug::helper::Fallback` is needed for the fallback to `Debug` impl
|
||||
parse_quote_spanned! {ident.span()=>
|
||||
impl #impl_generics ::std::fmt::Debug for #ident #type_generics
|
||||
#where_clause
|
||||
{
|
||||
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
|
||||
f.debug_struct(#ident_string)
|
||||
.field("[salsa id]", &self.salsa_id().as_u32())
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Generate `impl salsa::DebugWithDb for Foo`, but only if this is an id struct.
|
||||
pub(crate) fn as_debug_with_db_impl(&self) -> Option<syn::ItemImpl> {
|
||||
if self.customizations.contains(&Customization::DebugWithDb) {
|
||||
|
|
|
@ -67,6 +67,7 @@ impl TrackedStruct {
|
|||
let send_sync_impls = self.send_sync_impls();
|
||||
let from_id_impl = self.from_id_impl();
|
||||
let lookup_id_impl = self.lookup_id_impl();
|
||||
let debug_impl = self.debug_impl();
|
||||
let as_debug_with_db_impl = self.as_debug_with_db_impl();
|
||||
Ok(quote! {
|
||||
#config_struct
|
||||
|
@ -82,6 +83,7 @@ impl TrackedStruct {
|
|||
#(#send_sync_impls)*
|
||||
#lookup_id_impl
|
||||
#as_debug_with_db_impl
|
||||
#debug_impl
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -381,25 +381,19 @@ fn parse_print() {
|
|||
[salsa id]: 0,
|
||||
statements: [
|
||||
Statement {
|
||||
span: Span(
|
||||
Id {
|
||||
value: 5,
|
||||
},
|
||||
),
|
||||
span: Span {
|
||||
[salsa id]: 4,
|
||||
},
|
||||
data: Print(
|
||||
Expression {
|
||||
span: Span(
|
||||
Id {
|
||||
value: 4,
|
||||
},
|
||||
),
|
||||
span: Span {
|
||||
[salsa id]: 3,
|
||||
},
|
||||
data: Op(
|
||||
Expression {
|
||||
span: Span(
|
||||
Id {
|
||||
value: 1,
|
||||
},
|
||||
),
|
||||
span: Span {
|
||||
[salsa id]: 0,
|
||||
},
|
||||
data: Number(
|
||||
OrderedFloat(
|
||||
1.0,
|
||||
|
@ -408,11 +402,9 @@ fn parse_print() {
|
|||
},
|
||||
Add,
|
||||
Expression {
|
||||
span: Span(
|
||||
Id {
|
||||
value: 3,
|
||||
},
|
||||
),
|
||||
span: Span {
|
||||
[salsa id]: 2,
|
||||
},
|
||||
data: Number(
|
||||
OrderedFloat(
|
||||
2.0,
|
||||
|
@ -448,59 +440,43 @@ fn parse_example() {
|
|||
[salsa id]: 0,
|
||||
statements: [
|
||||
Statement {
|
||||
span: Span(
|
||||
Id {
|
||||
value: 10,
|
||||
},
|
||||
),
|
||||
span: Span {
|
||||
[salsa id]: 9,
|
||||
},
|
||||
data: Function(
|
||||
Function(
|
||||
Id {
|
||||
value: 1,
|
||||
},
|
||||
),
|
||||
Function {
|
||||
[salsa id]: 0,
|
||||
},
|
||||
),
|
||||
},
|
||||
Statement {
|
||||
span: Span(
|
||||
Id {
|
||||
value: 22,
|
||||
},
|
||||
),
|
||||
span: Span {
|
||||
[salsa id]: 21,
|
||||
},
|
||||
data: Function(
|
||||
Function(
|
||||
Id {
|
||||
value: 2,
|
||||
},
|
||||
),
|
||||
Function {
|
||||
[salsa id]: 1,
|
||||
},
|
||||
),
|
||||
},
|
||||
Statement {
|
||||
span: Span(
|
||||
Id {
|
||||
value: 29,
|
||||
},
|
||||
),
|
||||
span: Span {
|
||||
[salsa id]: 28,
|
||||
},
|
||||
data: Print(
|
||||
Expression {
|
||||
span: Span(
|
||||
Id {
|
||||
value: 28,
|
||||
},
|
||||
),
|
||||
span: Span {
|
||||
[salsa id]: 27,
|
||||
},
|
||||
data: Call(
|
||||
FunctionId(
|
||||
Id {
|
||||
value: 1,
|
||||
},
|
||||
),
|
||||
FunctionId {
|
||||
[salsa id]: 0,
|
||||
},
|
||||
[
|
||||
Expression {
|
||||
span: Span(
|
||||
Id {
|
||||
value: 24,
|
||||
},
|
||||
),
|
||||
span: Span {
|
||||
[salsa id]: 23,
|
||||
},
|
||||
data: Number(
|
||||
OrderedFloat(
|
||||
3.0,
|
||||
|
@ -508,11 +484,9 @@ fn parse_example() {
|
|||
),
|
||||
},
|
||||
Expression {
|
||||
span: Span(
|
||||
Id {
|
||||
value: 26,
|
||||
},
|
||||
),
|
||||
span: Span {
|
||||
[salsa id]: 25,
|
||||
},
|
||||
data: Number(
|
||||
OrderedFloat(
|
||||
4.0,
|
||||
|
@ -525,31 +499,23 @@ fn parse_example() {
|
|||
),
|
||||
},
|
||||
Statement {
|
||||
span: Span(
|
||||
Id {
|
||||
value: 34,
|
||||
},
|
||||
),
|
||||
span: Span {
|
||||
[salsa id]: 33,
|
||||
},
|
||||
data: Print(
|
||||
Expression {
|
||||
span: Span(
|
||||
Id {
|
||||
value: 33,
|
||||
},
|
||||
),
|
||||
span: Span {
|
||||
[salsa id]: 32,
|
||||
},
|
||||
data: Call(
|
||||
FunctionId(
|
||||
Id {
|
||||
value: 2,
|
||||
},
|
||||
),
|
||||
FunctionId {
|
||||
[salsa id]: 1,
|
||||
},
|
||||
[
|
||||
Expression {
|
||||
span: Span(
|
||||
Id {
|
||||
value: 31,
|
||||
},
|
||||
),
|
||||
span: Span {
|
||||
[salsa id]: 30,
|
||||
},
|
||||
data: Number(
|
||||
OrderedFloat(
|
||||
1.0,
|
||||
|
@ -562,25 +528,19 @@ fn parse_example() {
|
|||
),
|
||||
},
|
||||
Statement {
|
||||
span: Span(
|
||||
Id {
|
||||
value: 39,
|
||||
},
|
||||
),
|
||||
span: Span {
|
||||
[salsa id]: 38,
|
||||
},
|
||||
data: Print(
|
||||
Expression {
|
||||
span: Span(
|
||||
Id {
|
||||
value: 38,
|
||||
},
|
||||
),
|
||||
span: Span {
|
||||
[salsa id]: 37,
|
||||
},
|
||||
data: Op(
|
||||
Expression {
|
||||
span: Span(
|
||||
Id {
|
||||
value: 35,
|
||||
},
|
||||
),
|
||||
span: Span {
|
||||
[salsa id]: 34,
|
||||
},
|
||||
data: Number(
|
||||
OrderedFloat(
|
||||
11.0,
|
||||
|
@ -589,11 +549,9 @@ fn parse_example() {
|
|||
},
|
||||
Multiply,
|
||||
Expression {
|
||||
span: Span(
|
||||
Id {
|
||||
value: 37,
|
||||
},
|
||||
),
|
||||
span: Span {
|
||||
[salsa id]: 36,
|
||||
},
|
||||
data: Number(
|
||||
OrderedFloat(
|
||||
2.0,
|
||||
|
@ -644,32 +602,24 @@ fn parse_precedence() {
|
|||
[salsa id]: 0,
|
||||
statements: [
|
||||
Statement {
|
||||
span: Span(
|
||||
Id {
|
||||
value: 11,
|
||||
},
|
||||
),
|
||||
span: Span {
|
||||
[salsa id]: 10,
|
||||
},
|
||||
data: Print(
|
||||
Expression {
|
||||
span: Span(
|
||||
Id {
|
||||
value: 10,
|
||||
},
|
||||
),
|
||||
span: Span {
|
||||
[salsa id]: 9,
|
||||
},
|
||||
data: Op(
|
||||
Expression {
|
||||
span: Span(
|
||||
Id {
|
||||
value: 7,
|
||||
},
|
||||
),
|
||||
span: Span {
|
||||
[salsa id]: 6,
|
||||
},
|
||||
data: Op(
|
||||
Expression {
|
||||
span: Span(
|
||||
Id {
|
||||
value: 1,
|
||||
},
|
||||
),
|
||||
span: Span {
|
||||
[salsa id]: 0,
|
||||
},
|
||||
data: Number(
|
||||
OrderedFloat(
|
||||
1.0,
|
||||
|
@ -678,18 +628,14 @@ fn parse_precedence() {
|
|||
},
|
||||
Add,
|
||||
Expression {
|
||||
span: Span(
|
||||
Id {
|
||||
value: 6,
|
||||
},
|
||||
),
|
||||
span: Span {
|
||||
[salsa id]: 5,
|
||||
},
|
||||
data: Op(
|
||||
Expression {
|
||||
span: Span(
|
||||
Id {
|
||||
value: 3,
|
||||
},
|
||||
),
|
||||
span: Span {
|
||||
[salsa id]: 2,
|
||||
},
|
||||
data: Number(
|
||||
OrderedFloat(
|
||||
2.0,
|
||||
|
@ -698,11 +644,9 @@ fn parse_precedence() {
|
|||
},
|
||||
Multiply,
|
||||
Expression {
|
||||
span: Span(
|
||||
Id {
|
||||
value: 5,
|
||||
},
|
||||
),
|
||||
span: Span {
|
||||
[salsa id]: 4,
|
||||
},
|
||||
data: Number(
|
||||
OrderedFloat(
|
||||
3.0,
|
||||
|
@ -715,11 +659,9 @@ fn parse_precedence() {
|
|||
},
|
||||
Add,
|
||||
Expression {
|
||||
span: Span(
|
||||
Id {
|
||||
value: 9,
|
||||
},
|
||||
),
|
||||
span: Span {
|
||||
[salsa id]: 8,
|
||||
},
|
||||
data: Number(
|
||||
OrderedFloat(
|
||||
4.0,
|
||||
|
|
|
@ -75,9 +75,9 @@ fn test1() {
|
|||
assert_eq!(compute(&db, l2), 2);
|
||||
db.assert_logs(expect![[r#"
|
||||
[
|
||||
"compute(List(Id { value: 2 }))",
|
||||
"accumulated(List(Id { value: 1 }))",
|
||||
"compute(List(Id { value: 1 }))",
|
||||
"compute(List { [salsa id]: 1 })",
|
||||
"accumulated(List { [salsa id]: 0 })",
|
||||
"compute(List { [salsa id]: 0 })",
|
||||
]"#]]);
|
||||
|
||||
// When we mutate `l1`, we should re-execute `compute` for `l1`,
|
||||
|
@ -87,7 +87,7 @@ fn test1() {
|
|||
assert_eq!(compute(&db, l2), 2);
|
||||
db.assert_logs(expect![[r#"
|
||||
[
|
||||
"accumulated(List(Id { value: 1 }))",
|
||||
"compute(List(Id { value: 1 }))",
|
||||
"accumulated(List { [salsa id]: 0 })",
|
||||
"compute(List { [salsa id]: 0 })",
|
||||
]"#]]);
|
||||
}
|
||||
|
|
|
@ -70,8 +70,8 @@ fn test1() {
|
|||
assert_eq!(compute(&db, l2), 2);
|
||||
db.assert_logs(expect![[r#"
|
||||
[
|
||||
"compute(List(Id { value: 2 }))",
|
||||
"compute(List(Id { value: 1 }))",
|
||||
"compute(List { [salsa id]: 1 })",
|
||||
"compute(List { [salsa id]: 0 })",
|
||||
]"#]]);
|
||||
|
||||
// When we mutate `l1`, we should re-execute `compute` for `l1`,
|
||||
|
@ -82,7 +82,7 @@ fn test1() {
|
|||
assert_eq!(compute(&db, l2), 2);
|
||||
db.assert_logs(expect![[r#"
|
||||
[
|
||||
"compute(List(Id { value: 2 }))",
|
||||
"compute(List(Id { value: 1 }))",
|
||||
"compute(List { [salsa id]: 1 })",
|
||||
"compute(List { [salsa id]: 0 })",
|
||||
]"#]]);
|
||||
}
|
||||
|
|
|
@ -95,8 +95,8 @@ fn basic() {
|
|||
assert_eq!(final_result(&db, input), 2 * 2 + 2);
|
||||
db.assert_logs(expect![[r#"
|
||||
[
|
||||
"final_result(MyInput(Id { value: 1 }))",
|
||||
"intermediate_result(MyInput(Id { value: 1 }))",
|
||||
"final_result(MyInput { [salsa id]: 0 })",
|
||||
"intermediate_result(MyInput { [salsa id]: 0 })",
|
||||
]"#]]);
|
||||
|
||||
// Creates only 2 tracked structs in this revision, should delete 1
|
||||
|
@ -117,12 +117,12 @@ fn basic() {
|
|||
assert_eq!(final_result(&db, input), 2);
|
||||
db.assert_logs(expect![[r#"
|
||||
[
|
||||
"intermediate_result(MyInput(Id { value: 1 }))",
|
||||
"intermediate_result(MyInput { [salsa id]: 0 })",
|
||||
"salsa_event(WillDiscardStaleOutput { execute_key: create_tracked_structs(0), output_key: MyTracked(2) })",
|
||||
"salsa_event(DidDiscard { key: MyTracked(2) })",
|
||||
"salsa_event(DidDiscard { key: contribution_from_struct(2) })",
|
||||
"salsa_event(DidDiscard { key: MyTracked(5) })",
|
||||
"salsa_event(DidDiscard { key: copy_field(5) })",
|
||||
"final_result(MyInput(Id { value: 1 }))",
|
||||
"final_result(MyInput { [salsa id]: 0 })",
|
||||
]"#]]);
|
||||
}
|
||||
|
|
|
@ -88,8 +88,8 @@ fn basic() {
|
|||
assert_eq!(final_result(&db, input), 2 * 2 + 2);
|
||||
db.assert_logs(expect![[r#"
|
||||
[
|
||||
"final_result(MyInput(Id { value: 1 }))",
|
||||
"intermediate_result(MyInput(Id { value: 1 }))",
|
||||
"final_result(MyInput { [salsa id]: 0 })",
|
||||
"intermediate_result(MyInput { [salsa id]: 0 })",
|
||||
]"#]]);
|
||||
|
||||
// Creates only 2 tracked structs in this revision, should delete 1
|
||||
|
@ -103,10 +103,10 @@ fn basic() {
|
|||
assert_eq!(final_result(&db, input), 2);
|
||||
db.assert_logs(expect![[r#"
|
||||
[
|
||||
"intermediate_result(MyInput(Id { value: 1 }))",
|
||||
"intermediate_result(MyInput { [salsa id]: 0 })",
|
||||
"salsa_event(WillDiscardStaleOutput { execute_key: create_tracked_structs(0), output_key: MyTracked(2) })",
|
||||
"salsa_event(DidDiscard { key: MyTracked(2) })",
|
||||
"salsa_event(DidDiscard { key: contribution_from_struct(2) })",
|
||||
"final_result(MyInput(Id { value: 1 }))",
|
||||
"final_result(MyInput { [salsa id]: 0 })",
|
||||
]"#]]);
|
||||
}
|
||||
|
|
|
@ -78,13 +78,13 @@ fn execute() {
|
|||
assert_eq!(final_result_depends_on_x(&db, input), 22);
|
||||
db.assert_logs(expect![[r#"
|
||||
[
|
||||
"final_result_depends_on_x(MyInput(Id { value: 1 }))",
|
||||
"final_result_depends_on_x(MyInput { [salsa id]: 0 })",
|
||||
]"#]]);
|
||||
|
||||
assert_eq!(final_result_depends_on_y(&db, input), 22);
|
||||
db.assert_logs(expect![[r#"
|
||||
[
|
||||
"final_result_depends_on_y(MyInput(Id { value: 1 }))",
|
||||
"final_result_depends_on_y(MyInput { [salsa id]: 0 })",
|
||||
]"#]]);
|
||||
|
||||
input.set_field(&mut db).to(23);
|
||||
|
@ -94,7 +94,7 @@ fn execute() {
|
|||
assert_eq!(final_result_depends_on_x(&db, input), 24);
|
||||
db.assert_logs(expect![[r#"
|
||||
[
|
||||
"final_result_depends_on_x(MyInput(Id { value: 1 }))",
|
||||
"final_result_depends_on_x(MyInput { [salsa id]: 0 })",
|
||||
]"#]]);
|
||||
|
||||
// y = 23 / 2 = 11
|
||||
|
|
|
@ -57,13 +57,13 @@ fn execute() {
|
|||
assert_eq!(result_depends_on_x(&db, input), 23);
|
||||
db.assert_logs(expect![[r#"
|
||||
[
|
||||
"result_depends_on_x(MyInput(Id { value: 1 }))",
|
||||
"result_depends_on_x(MyInput { [salsa id]: 0 })",
|
||||
]"#]]);
|
||||
|
||||
assert_eq!(result_depends_on_y(&db, input), 32);
|
||||
db.assert_logs(expect![[r#"
|
||||
[
|
||||
"result_depends_on_y(MyInput(Id { value: 1 }))",
|
||||
"result_depends_on_y(MyInput { [salsa id]: 0 })",
|
||||
]"#]]);
|
||||
|
||||
input.set_x(&mut db).to(23);
|
||||
|
@ -71,7 +71,7 @@ fn execute() {
|
|||
assert_eq!(result_depends_on_x(&db, input), 24);
|
||||
db.assert_logs(expect![[r#"
|
||||
[
|
||||
"result_depends_on_x(MyInput(Id { value: 1 }))",
|
||||
"result_depends_on_x(MyInput { [salsa id]: 0 })",
|
||||
]"#]]);
|
||||
|
||||
// input y is the same, so result depends on y
|
||||
|
|
|
@ -58,8 +58,8 @@ fn execute() {
|
|||
assert_eq!(final_result(&db, input), 22);
|
||||
db.assert_logs(expect![[r#"
|
||||
[
|
||||
"final_result(MyInput(Id { value: 1 }))",
|
||||
"intermediate_result(MyInput(Id { value: 1 }))",
|
||||
"final_result(MyInput { [salsa id]: 0 })",
|
||||
"intermediate_result(MyInput { [salsa id]: 0 })",
|
||||
]"#]]);
|
||||
|
||||
// Intermediate result is the same, so final result does
|
||||
|
@ -68,15 +68,15 @@ fn execute() {
|
|||
assert_eq!(final_result(&db, input), 22);
|
||||
db.assert_logs(expect![[r#"
|
||||
[
|
||||
"intermediate_result(MyInput(Id { value: 1 }))",
|
||||
"intermediate_result(MyInput { [salsa id]: 0 })",
|
||||
]"#]]);
|
||||
|
||||
input.set_field(&mut db).to(24);
|
||||
assert_eq!(final_result(&db, input), 24);
|
||||
db.assert_logs(expect![[r#"
|
||||
[
|
||||
"intermediate_result(MyInput(Id { value: 1 }))",
|
||||
"final_result(MyInput(Id { value: 1 }))",
|
||||
"intermediate_result(MyInput { [salsa id]: 0 })",
|
||||
"final_result(MyInput { [salsa id]: 0 })",
|
||||
]"#]]);
|
||||
}
|
||||
|
||||
|
@ -89,8 +89,8 @@ fn red_herring() {
|
|||
assert_eq!(final_result(&db, input), 22);
|
||||
db.assert_logs(expect![[r#"
|
||||
[
|
||||
"final_result(MyInput(Id { value: 1 }))",
|
||||
"intermediate_result(MyInput(Id { value: 1 }))",
|
||||
"final_result(MyInput { [salsa id]: 0 })",
|
||||
"intermediate_result(MyInput { [salsa id]: 0 })",
|
||||
]"#]]);
|
||||
|
||||
// Create a distinct input and mutate it.
|
||||
|
|
|
@ -95,13 +95,13 @@ fn test_run_0() {
|
|||
[
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillCheckCancellation }",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillExecute { database_key: final_result(0) } }",
|
||||
"final_result(MyInput(Id { value: 1 }))",
|
||||
"final_result(MyInput { [salsa id]: 0 })",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillCheckCancellation }",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillExecute { database_key: create_tracked(0) } }",
|
||||
"create_tracked(MyInput(Id { value: 1 }))",
|
||||
"create_tracked(MyInput { [salsa id]: 0 })",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillCheckCancellation }",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillExecute { database_key: read_maybe_specified(0) } }",
|
||||
"read_maybe_specified(MyTracked(Id { value: 1 }))",
|
||||
"read_maybe_specified(MyTracked { [salsa id]: 0 })",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillCheckCancellation }",
|
||||
]"#]]);
|
||||
}
|
||||
|
@ -116,13 +116,13 @@ fn test_run_5() {
|
|||
[
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillCheckCancellation }",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillExecute { database_key: final_result(0) } }",
|
||||
"final_result(MyInput(Id { value: 1 }))",
|
||||
"final_result(MyInput { [salsa id]: 0 })",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillCheckCancellation }",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillExecute { database_key: create_tracked(0) } }",
|
||||
"create_tracked(MyInput(Id { value: 1 }))",
|
||||
"create_tracked(MyInput { [salsa id]: 0 })",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillCheckCancellation }",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillExecute { database_key: read_maybe_specified(0) } }",
|
||||
"read_maybe_specified(MyTracked(Id { value: 1 }))",
|
||||
"read_maybe_specified(MyTracked { [salsa id]: 0 })",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillCheckCancellation }",
|
||||
]"#]]);
|
||||
}
|
||||
|
@ -137,16 +137,16 @@ fn test_run_10() {
|
|||
[
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillCheckCancellation }",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillExecute { database_key: final_result(0) } }",
|
||||
"final_result(MyInput(Id { value: 1 }))",
|
||||
"final_result(MyInput { [salsa id]: 0 })",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillCheckCancellation }",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillExecute { database_key: create_tracked(0) } }",
|
||||
"create_tracked(MyInput(Id { value: 1 }))",
|
||||
"create_tracked(MyInput { [salsa id]: 0 })",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillCheckCancellation }",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillExecute { database_key: read_maybe_specified(0) } }",
|
||||
"read_maybe_specified(MyTracked(Id { value: 1 }))",
|
||||
"read_maybe_specified(MyTracked { [salsa id]: 0 })",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillCheckCancellation }",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillExecute { database_key: maybe_specified(0) } }",
|
||||
"maybe_specified(MyTracked(Id { value: 1 }))",
|
||||
"maybe_specified(MyTracked { [salsa id]: 0 })",
|
||||
]"#]]);
|
||||
}
|
||||
|
||||
|
@ -160,16 +160,16 @@ fn test_run_20() {
|
|||
[
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillCheckCancellation }",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillExecute { database_key: final_result(0) } }",
|
||||
"final_result(MyInput(Id { value: 1 }))",
|
||||
"final_result(MyInput { [salsa id]: 0 })",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillCheckCancellation }",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillExecute { database_key: create_tracked(0) } }",
|
||||
"create_tracked(MyInput(Id { value: 1 }))",
|
||||
"create_tracked(MyInput { [salsa id]: 0 })",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillCheckCancellation }",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillExecute { database_key: read_maybe_specified(0) } }",
|
||||
"read_maybe_specified(MyTracked(Id { value: 1 }))",
|
||||
"read_maybe_specified(MyTracked { [salsa id]: 0 })",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillCheckCancellation }",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillExecute { database_key: maybe_specified(0) } }",
|
||||
"maybe_specified(MyTracked(Id { value: 1 }))",
|
||||
"maybe_specified(MyTracked { [salsa id]: 0 })",
|
||||
]"#]]);
|
||||
}
|
||||
|
||||
|
@ -187,13 +187,13 @@ fn test_run_0_then_5_then_20() {
|
|||
[
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillCheckCancellation }",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillExecute { database_key: final_result(0) } }",
|
||||
"final_result(MyInput(Id { value: 1 }))",
|
||||
"final_result(MyInput { [salsa id]: 0 })",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillCheckCancellation }",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillExecute { database_key: create_tracked(0) } }",
|
||||
"create_tracked(MyInput(Id { value: 1 }))",
|
||||
"create_tracked(MyInput { [salsa id]: 0 })",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillCheckCancellation }",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillExecute { database_key: read_maybe_specified(0) } }",
|
||||
"read_maybe_specified(MyTracked(Id { value: 1 }))",
|
||||
"read_maybe_specified(MyTracked { [salsa id]: 0 })",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillCheckCancellation }",
|
||||
]"#]]);
|
||||
|
||||
|
@ -208,7 +208,7 @@ fn test_run_0_then_5_then_20() {
|
|||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillCheckCancellation }",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillCheckCancellation }",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillExecute { database_key: create_tracked(0) } }",
|
||||
"create_tracked(MyInput(Id { value: 1 }))",
|
||||
"create_tracked(MyInput { [salsa id]: 0 })",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillCheckCancellation }",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillCheckCancellation }",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: DidValidateMemoizedValue { database_key: read_maybe_specified(0) } }",
|
||||
|
@ -227,17 +227,17 @@ fn test_run_0_then_5_then_20() {
|
|||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillCheckCancellation }",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillCheckCancellation }",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillExecute { database_key: create_tracked(0) } }",
|
||||
"create_tracked(MyInput(Id { value: 1 }))",
|
||||
"create_tracked(MyInput { [salsa id]: 0 })",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillDiscardStaleOutput { execute_key: create_tracked(0), output_key: maybe_specified(0) } }",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillCheckCancellation }",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillCheckCancellation }",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillExecute { database_key: maybe_specified(0) } }",
|
||||
"maybe_specified(MyTracked(Id { value: 1 }))",
|
||||
"maybe_specified(MyTracked { [salsa id]: 0 })",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillExecute { database_key: read_maybe_specified(0) } }",
|
||||
"read_maybe_specified(MyTracked(Id { value: 1 }))",
|
||||
"read_maybe_specified(MyTracked { [salsa id]: 0 })",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillCheckCancellation }",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillExecute { database_key: final_result(0) } }",
|
||||
"final_result(MyInput(Id { value: 1 }))",
|
||||
"final_result(MyInput { [salsa id]: 0 })",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillCheckCancellation }",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillCheckCancellation }",
|
||||
]"#]]);
|
||||
|
@ -257,13 +257,13 @@ fn test_run_0_then_5_then_10_then_20() {
|
|||
[
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillCheckCancellation }",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillExecute { database_key: final_result(0) } }",
|
||||
"final_result(MyInput(Id { value: 1 }))",
|
||||
"final_result(MyInput { [salsa id]: 0 })",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillCheckCancellation }",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillExecute { database_key: create_tracked(0) } }",
|
||||
"create_tracked(MyInput(Id { value: 1 }))",
|
||||
"create_tracked(MyInput { [salsa id]: 0 })",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillCheckCancellation }",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillExecute { database_key: read_maybe_specified(0) } }",
|
||||
"read_maybe_specified(MyTracked(Id { value: 1 }))",
|
||||
"read_maybe_specified(MyTracked { [salsa id]: 0 })",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillCheckCancellation }",
|
||||
]"#]]);
|
||||
|
||||
|
@ -278,7 +278,7 @@ fn test_run_0_then_5_then_10_then_20() {
|
|||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillCheckCancellation }",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillCheckCancellation }",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillExecute { database_key: create_tracked(0) } }",
|
||||
"create_tracked(MyInput(Id { value: 1 }))",
|
||||
"create_tracked(MyInput { [salsa id]: 0 })",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillCheckCancellation }",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillCheckCancellation }",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: DidValidateMemoizedValue { database_key: read_maybe_specified(0) } }",
|
||||
|
@ -297,12 +297,12 @@ fn test_run_0_then_5_then_10_then_20() {
|
|||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillCheckCancellation }",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillCheckCancellation }",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillExecute { database_key: create_tracked(0) } }",
|
||||
"create_tracked(MyInput(Id { value: 1 }))",
|
||||
"create_tracked(MyInput { [salsa id]: 0 })",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillDiscardStaleOutput { execute_key: create_tracked(0), output_key: maybe_specified(0) } }",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillCheckCancellation }",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillCheckCancellation }",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillExecute { database_key: maybe_specified(0) } }",
|
||||
"maybe_specified(MyTracked(Id { value: 1 }))",
|
||||
"maybe_specified(MyTracked { [salsa id]: 0 })",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: DidValidateMemoizedValue { database_key: read_maybe_specified(0) } }",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: DidValidateMemoizedValue { database_key: final_result(0) } }",
|
||||
]"#]]);
|
||||
|
@ -317,16 +317,16 @@ fn test_run_0_then_5_then_10_then_20() {
|
|||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillCheckCancellation }",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillCheckCancellation }",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillExecute { database_key: create_tracked(0) } }",
|
||||
"create_tracked(MyInput(Id { value: 1 }))",
|
||||
"create_tracked(MyInput { [salsa id]: 0 })",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillCheckCancellation }",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillCheckCancellation }",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillExecute { database_key: maybe_specified(0) } }",
|
||||
"maybe_specified(MyTracked(Id { value: 1 }))",
|
||||
"maybe_specified(MyTracked { [salsa id]: 0 })",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillExecute { database_key: read_maybe_specified(0) } }",
|
||||
"read_maybe_specified(MyTracked(Id { value: 1 }))",
|
||||
"read_maybe_specified(MyTracked { [salsa id]: 0 })",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillCheckCancellation }",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillExecute { database_key: final_result(0) } }",
|
||||
"final_result(MyInput(Id { value: 1 }))",
|
||||
"final_result(MyInput { [salsa id]: 0 })",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillCheckCancellation }",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillCheckCancellation }",
|
||||
]"#]]);
|
||||
|
@ -342,13 +342,13 @@ fn test_run_5_then_20() {
|
|||
[
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillCheckCancellation }",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillExecute { database_key: final_result(0) } }",
|
||||
"final_result(MyInput(Id { value: 1 }))",
|
||||
"final_result(MyInput { [salsa id]: 0 })",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillCheckCancellation }",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillExecute { database_key: create_tracked(0) } }",
|
||||
"create_tracked(MyInput(Id { value: 1 }))",
|
||||
"create_tracked(MyInput { [salsa id]: 0 })",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillCheckCancellation }",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillExecute { database_key: read_maybe_specified(0) } }",
|
||||
"read_maybe_specified(MyTracked(Id { value: 1 }))",
|
||||
"read_maybe_specified(MyTracked { [salsa id]: 0 })",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillCheckCancellation }",
|
||||
]"#]]);
|
||||
|
||||
|
@ -359,17 +359,17 @@ fn test_run_5_then_20() {
|
|||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillCheckCancellation }",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillCheckCancellation }",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillExecute { database_key: create_tracked(0) } }",
|
||||
"create_tracked(MyInput(Id { value: 1 }))",
|
||||
"create_tracked(MyInput { [salsa id]: 0 })",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillDiscardStaleOutput { execute_key: create_tracked(0), output_key: maybe_specified(0) } }",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillCheckCancellation }",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillCheckCancellation }",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillExecute { database_key: maybe_specified(0) } }",
|
||||
"maybe_specified(MyTracked(Id { value: 1 }))",
|
||||
"maybe_specified(MyTracked { [salsa id]: 0 })",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillExecute { database_key: read_maybe_specified(0) } }",
|
||||
"read_maybe_specified(MyTracked(Id { value: 1 }))",
|
||||
"read_maybe_specified(MyTracked { [salsa id]: 0 })",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillCheckCancellation }",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillExecute { database_key: final_result(0) } }",
|
||||
"final_result(MyInput(Id { value: 1 }))",
|
||||
"final_result(MyInput { [salsa id]: 0 })",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillCheckCancellation }",
|
||||
"Event { runtime_id: RuntimeId { counter: 0 }, kind: WillCheckCancellation }",
|
||||
]"#]]);
|
||||
|
|
|
@ -59,8 +59,8 @@ fn one_entity() {
|
|||
assert_eq!(final_result(&db, input), 22);
|
||||
db.assert_logs(expect![[r#"
|
||||
[
|
||||
"final_result(MyInput(Id { value: 1 }))",
|
||||
"intermediate_result(MyInput(Id { value: 1 }))",
|
||||
"final_result(MyInput { [salsa id]: 0 })",
|
||||
"intermediate_result(MyInput { [salsa id]: 0 })",
|
||||
]"#]]);
|
||||
|
||||
// Intermediate result is the same, so final result does
|
||||
|
@ -69,15 +69,15 @@ fn one_entity() {
|
|||
assert_eq!(final_result(&db, input), 22);
|
||||
db.assert_logs(expect![[r#"
|
||||
[
|
||||
"intermediate_result(MyInput(Id { value: 1 }))",
|
||||
"intermediate_result(MyInput { [salsa id]: 0 })",
|
||||
]"#]]);
|
||||
|
||||
input.set_field(&mut db).to(24);
|
||||
assert_eq!(final_result(&db, input), 24);
|
||||
db.assert_logs(expect![[r#"
|
||||
[
|
||||
"intermediate_result(MyInput(Id { value: 1 }))",
|
||||
"final_result(MyInput(Id { value: 1 }))",
|
||||
"intermediate_result(MyInput { [salsa id]: 0 })",
|
||||
"final_result(MyInput { [salsa id]: 0 })",
|
||||
]"#]]);
|
||||
}
|
||||
|
||||
|
@ -90,8 +90,8 @@ fn red_herring() {
|
|||
assert_eq!(final_result(&db, input), 22);
|
||||
db.assert_logs(expect![[r#"
|
||||
[
|
||||
"final_result(MyInput(Id { value: 1 }))",
|
||||
"intermediate_result(MyInput(Id { value: 1 }))",
|
||||
"final_result(MyInput { [salsa id]: 0 })",
|
||||
"intermediate_result(MyInput { [salsa id]: 0 })",
|
||||
]"#]]);
|
||||
|
||||
// Create a distinct input and mutate it.
|
||||
|
|
|
@ -57,10 +57,9 @@ fn execute() {
|
|||
field: "foo",
|
||||
},
|
||||
next: Next(
|
||||
MyTracked(
|
||||
0x00007fc15c011010,
|
||||
PhantomData<&salsa_2022::tracked_struct::ValueStruct<tracked_with_struct_db::__MyTrackedConfig>>,
|
||||
),
|
||||
MyTracked {
|
||||
[salsa id]: 0,
|
||||
},
|
||||
),
|
||||
}
|
||||
"#]].assert_debug_eq(&t0.debug(&db));
|
||||
|
|
Loading…
Reference in a new issue