File tree Expand file tree Collapse file tree 2 files changed +39
-0
lines changed Expand file tree Collapse file tree 2 files changed +39
-0
lines changed Original file line number Diff line number Diff line change 1+ //! Regression test for clippy::double_parens warnings in cycle macros.
2+ //!
3+ //! This test ensures that tracked functions with no additional inputs (beyond `db`)
4+ //! don't trigger clippy::double_parens warnings when using cycle_initial or cycle_fn.
5+ //!
6+ //! Before the fix in components/salsa-macro-rules/src/unexpected_cycle_recovery.rs,
7+ //! these macros would generate `std::mem::drop(())` which triggered the warning.
8+ //!
9+ //! See: https://github.com/salsa-rs/salsa/issues/1004
10+
11+ // This tracked function has no additional inputs beyond `db`.
12+ // With the old code, this would trigger clippy::double_parens warnings in the
13+ // generated `unexpected_cycle_initial` and `unexpected_cycle_recovery` macros.
14+ #[ salsa:: tracked]
15+ fn simple_tracked_query ( _db : & dyn salsa:: Database ) -> u32 {
16+ 100
17+ }
18+
19+ // Tracked function with cycle recovery and no additional inputs.
20+ // The cycle_initial and cycle_fn functions also have no additional inputs beyond `db`,
21+ // which would trigger the clippy warning with the old code.
22+ #[ salsa:: tracked( cycle_fn=cycle_recover, cycle_initial=initial) ]
23+ fn query_with_cycle_support ( _db : & dyn salsa:: Database ) -> u32 {
24+ 200
25+ }
26+
27+ fn initial ( _db : & dyn salsa:: Database ) -> u32 {
28+ 0
29+ }
30+
31+ fn cycle_recover (
32+ _db : & dyn salsa:: Database ,
33+ value : & u32 ,
34+ _count : u32 ,
35+ ) -> salsa:: CycleRecoveryAction < u32 > {
36+ // Just return the value to avoid actual cycling in this test
37+ salsa:: CycleRecoveryAction :: Fallback ( * value)
38+ }
Original file line number Diff line number Diff line change 22
33#![ deny( warnings) ]
44
5+ mod double_parens;
56mod needless_borrow;
67mod needless_lifetimes;
78mod unused_variable_db;
You can’t perform that action at this time.
0 commit comments