File tree Expand file tree Collapse file tree 1 file changed +7
-7
lines changed
crates/ruff_linter/src/fix Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -130,13 +130,13 @@ fn apply_fixes<'a>(
130130/// Compare two fixes.
131131fn cmp_fix ( rule1 : Rule , rule2 : Rule , fix1 : & Fix , fix2 : & Fix ) -> std:: cmp:: Ordering {
132132 // Always apply `RedefinedWhileUnused` before `UnusedImport`, as the latter can end up fixing
133- // the former.
134- {
135- match ( rule1 , rule2 ) {
136- ( Rule :: RedefinedWhileUnused , Rule :: UnusedImport ) => return std :: cmp :: Ordering :: Less ,
137- ( Rule :: UnusedImport , Rule :: RedefinedWhileUnused ) => return std:: cmp:: Ordering :: Greater ,
138- _ => std:: cmp:: Ordering :: Equal ,
139- }
133+ // the former. But we can't apply this just for `RedefinedWhileUnused` and `UnusedImport` because it violates
134+ // `< is transitive: a < b and b < c implies a < c. The same must hold for both == and >.`
135+ // See https://github.com/astral-sh/ruff/issues/12469#issuecomment-2244392085
136+ match ( rule1 , rule2 ) {
137+ ( Rule :: RedefinedWhileUnused , _ ) => std:: cmp:: Ordering :: Less ,
138+ ( _ , Rule :: RedefinedWhileUnused ) => std:: cmp:: Ordering :: Greater ,
139+ _ => std :: cmp :: Ordering :: Equal ,
140140 }
141141 // Apply fixes in order of their start position.
142142 . then_with ( || fix1. min_start ( ) . cmp ( & fix2. min_start ( ) ) )
You can’t perform that action at this time.
0 commit comments