@@ -12,29 +12,24 @@ struct List {
1212 next : Option < List > ,
1313}
1414
15+ // Silence a warning about this not being used (it is).
16+ #[ allow( unused) ]
1517#[ salsa:: accumulator]
1618#[ derive( Copy , Clone , Debug ) ]
1719struct Integers ( u32 ) ;
1820
1921#[ salsa:: tracked]
2022fn 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) ;
3833}
3934
4035#[ test]
@@ -48,7 +43,7 @@ fn test1() {
4843 expect ! [ [ r#"
4944 [
5045 Integers(
51- 11 ,
46+ 10 ,
5247 ),
5348 Integers(
5449 1,
@@ -62,7 +57,21 @@ fn test1() {
6257 expect ! [ [ r#"
6358 [
6459 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,
6675 ),
6776 Integers(
6877 2,
0 commit comments