ruff
ruff copied to clipboard
`red-knot`: introduce a `StatisticsRecorder` trait for the `KeyValueCache`
Summary
This PR changes the DebugStatistics and ReleaseStatistics structs so that they implement a common StatisticsRecorder trait, and makes the KeyValueCache struct generic over a type parameter bound to that trait. The advantage of this approach is that it's much harder for the DebugStatistics and ReleaseStatistics structs to accidentally grow out of sync in the methods that they implement, which was the cause of the release-build failure recently fixed in #11177.
Test Plan
cargo test -p red_knot and cargo build --release both continue to pass for me locally
ruff-ecosystem results
Linter (stable)
✅ ecosystem check detected no linter changes.
Linter (preview)
✅ ecosystem check detected no linter changes.
Going to let @MichaReiser confirm if this looks ok.