Apply redefinition fixes by source code order (#15575)

## Summary

Right now, these are being applied in random order, since if we have two
`RedefinitionWhileUnused`, it just takes the first-generated (whereas
the next comparator in the sort here orders by location)... Which means
we frequently have to re-run!
This commit is contained in:
Charlie Marsh 2025-01-18 17:44:10 -05:00 committed by GitHub
parent 1344c8a4e2
commit 6004c8c003
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -134,6 +134,7 @@ fn cmp_fix(rule1: Rule, rule2: Rule, fix1: &Fix, fix2: &Fix) -> std::cmp::Orderi
// `< is transitive: a < b and b < c implies a < c. The same must hold for both == and >.` // `< is transitive: a < b and b < c implies a < c. The same must hold for both == and >.`
// See https://github.com/astral-sh/ruff/issues/12469#issuecomment-2244392085 // See https://github.com/astral-sh/ruff/issues/12469#issuecomment-2244392085
match (rule1, rule2) { match (rule1, rule2) {
(Rule::RedefinedWhileUnused, Rule::RedefinedWhileUnused) => std::cmp::Ordering::Equal,
(Rule::RedefinedWhileUnused, _) => std::cmp::Ordering::Less, (Rule::RedefinedWhileUnused, _) => std::cmp::Ordering::Less,
(_, Rule::RedefinedWhileUnused) => std::cmp::Ordering::Greater, (_, Rule::RedefinedWhileUnused) => std::cmp::Ordering::Greater,
_ => std::cmp::Ordering::Equal, _ => std::cmp::Ordering::Equal,