Skip to content

Commit 656d901

Browse files
committed
reorder: use versionsort for item names
1 parent 91d4240 commit 656d901

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

src/items.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ use crate::expr::{
2323
use crate::lists::{definitive_tactic, itemize_list, write_list, ListFormatting, Separator};
2424
use crate::macros::{rewrite_macro, MacroPosition};
2525
use crate::overflow;
26+
use crate::reorder::compare_as_versions;
2627
use crate::rewrite::{Rewrite, RewriteContext};
2728
use crate::shape::{Indent, Shape};
2829
use crate::source_map::{LineRangeUtils, SpanUtils};
@@ -604,7 +605,9 @@ impl<'a> FmtVisitor<'a> {
604605
(Type(..), Type(..))
605606
| (Const(..), Const(..))
606607
| (Macro(..), Macro(..))
607-
| (Existential(..), Existential(..)) => a.ident.as_str().cmp(&b.ident.as_str()),
608+
| (Existential(..), Existential(..)) => {
609+
compare_as_versions(&a.ident.as_str(), &b.ident.as_str())
610+
}
608611
(Method(..), Method(..)) => a.span.lo().cmp(&b.span.lo()),
609612
(Type(..), _) => Ordering::Less,
610613
(_, Type(..)) => Ordering::Greater,

tests/source/issue-2863.rs

+2
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,6 @@ impl<T> IntoIterator for SafeVec<T> {
2222
existential type E: Trait;
2323
const AnotherConst: i32 = 100;
2424
fn foo8() {println!("hello, world");}
25+
const AnyConst10: i32 = 100;
26+
const AnyConst2: i32 = 100;
2527
}

tests/target/issue-2863.rs

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ impl<T> IntoIterator for SafeVec<T> {
1313
existential type F: Trait;
1414

1515
const AnotherConst: i32 = 100;
16+
const AnyConst2: i32 = 100;
17+
const AnyConst10: i32 = 100;
1618
const SomeConst: i32 = 100;
1719

1820
// comment on foo()

0 commit comments

Comments
 (0)