Skip to content

Commit 4f3b166

Browse files
committed
reorder: restore fallback comparison by alias
The tests were modified in fa75ef4 (part of #2535), probably accidentally as the comments documenting the old expectations were kept.
1 parent e512cd5 commit 4f3b166

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

rustfmt-core/rustfmt-lib/src/imports.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,8 @@ impl Ord for UseTree {
726726
}
727727
}
728728

729-
self.path.len().cmp(&other.path.len())
729+
Ord::cmp(&self.path.len(), &other.path.len())
730+
.then(Ord::cmp(&self.path.last(), &other.path.last()))
730731
}
731732
}
732733

rustfmt-core/rustfmt-lib/tests/target/imports-reorder-lines.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ use aaa::*;
1515
mod test {}
1616
// If item names are equal, order by rename
1717

18-
use test::{a as bb, b};
1918
use test::{a as aa, c};
19+
use test::{a as bb, b};
2020

2121
mod test {}
2222
// If item names are equal, order by rename - no rename comes before a rename
2323

24-
use test::{a as bb, b};
2524
use test::{a, c};
25+
use test::{a as bb, b};
2626

2727
mod test {}
2828
// `self` always comes first

0 commit comments

Comments
 (0)