@@ -12,29 +12,24 @@ struct List {
12
12
next : Option < List > ,
13
13
}
14
14
15
+ // Silence a warning about this not being used (it is).
16
+ #[ allow( unused) ]
15
17
#[ salsa:: accumulator]
16
18
#[ derive( Copy , Clone , Debug ) ]
17
19
struct Integers ( u32 ) ;
18
20
19
21
#[ salsa:: tracked]
20
22
fn compute ( db : & dyn salsa:: Database , input : List ) {
21
- eprintln ! (
22
- "{:?}(value={:?}, next={:?})" ,
23
- input,
24
- input. value( db) ,
25
- input. next( db)
26
- ) ;
27
- let result = if let Some ( next) = input. next ( db) {
28
- let next_integers = compute:: accumulated :: < Integers > ( db, next) ;
29
- eprintln ! ( "{next_integers:?}" ) ;
30
- let v = input. value ( db) + next_integers. iter ( ) . map ( |a| a. 0 ) . sum :: < u32 > ( ) ;
31
- eprintln ! ( "input={:?} v={:?}" , input. value( db) , v) ;
32
- v
33
- } else {
34
- input. value ( db)
35
- } ;
36
- Integers ( result) . accumulate ( db) ;
37
- eprintln ! ( "pushed result {result:?}" ) ;
23
+ compute_single ( db, input) ;
24
+ if let Some ( next) = input. next ( db) {
25
+ compute ( db, next) ;
26
+ }
27
+ }
28
+
29
+ // In https://github.com/salsa-rs/salsa/issues/923 there was an issue specifically with tracked fn calling tracked fn.
30
+ #[ salsa:: tracked]
31
+ fn compute_single ( db : & dyn salsa:: Database , input : List ) {
32
+ Integers ( input. value ( db) ) . accumulate ( db) ;
38
33
}
39
34
40
35
#[ test]
@@ -48,7 +43,7 @@ fn test1() {
48
43
expect ! [ [ r#"
49
44
[
50
45
Integers(
51
- 11 ,
46
+ 10 ,
52
47
),
53
48
Integers(
54
49
1,
@@ -62,7 +57,21 @@ fn test1() {
62
57
expect ! [ [ r#"
63
58
[
64
59
Integers(
65
- 12,
60
+ 10,
61
+ ),
62
+ Integers(
63
+ 2,
64
+ ),
65
+ ]
66
+ "# ] ]
67
+ . assert_debug_eq ( & compute:: accumulated :: < Integers > ( & db, l1) ) ;
68
+
69
+ l1. set_value ( & mut db) . to ( 11 ) ;
70
+ compute ( & db, l1) ;
71
+ expect ! [ [ r#"
72
+ [
73
+ Integers(
74
+ 11,
66
75
),
67
76
Integers(
68
77
2,
0 commit comments