File tree Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Expand file tree Collapse file tree 2 files changed +40
-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+ #[ allow( dead_code) ]
24+ fn query_with_cycle_support ( _db : & dyn salsa:: Database ) -> u32 {
25+ 200
26+ }
27+
28+ fn initial ( _db : & dyn salsa:: Database ) -> u32 {
29+ 0
30+ }
31+
32+ fn cycle_recover (
33+ _db : & dyn salsa:: Database ,
34+ value : & u32 ,
35+ _count : u32 ,
36+ ) -> salsa:: CycleRecoveryAction < u32 > {
37+ // Just return the value to avoid actual cycling in this test
38+ salsa:: CycleRecoveryAction :: Fallback ( * value)
39+ }
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