Skip to content

Commit

Permalink
reorder: use versionsort for item names
Browse files Browse the repository at this point in the history
  • Loading branch information
tanriol committed Aug 29, 2019
1 parent 91d4240 commit 656d901
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use crate::expr::{
use crate::lists::{definitive_tactic, itemize_list, write_list, ListFormatting, Separator};
use crate::macros::{rewrite_macro, MacroPosition};
use crate::overflow;
use crate::reorder::compare_as_versions;
use crate::rewrite::{Rewrite, RewriteContext};
use crate::shape::{Indent, Shape};
use crate::source_map::{LineRangeUtils, SpanUtils};
Expand Down Expand Up @@ -604,7 +605,9 @@ impl<'a> FmtVisitor<'a> {
(Type(..), Type(..))
| (Const(..), Const(..))
| (Macro(..), Macro(..))
| (Existential(..), Existential(..)) => a.ident.as_str().cmp(&b.ident.as_str()),
| (Existential(..), Existential(..)) => {
compare_as_versions(&a.ident.as_str(), &b.ident.as_str())
}
(Method(..), Method(..)) => a.span.lo().cmp(&b.span.lo()),
(Type(..), _) => Ordering::Less,
(_, Type(..)) => Ordering::Greater,
Expand Down
2 changes: 2 additions & 0 deletions tests/source/issue-2863.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,6 @@ impl<T> IntoIterator for SafeVec<T> {
existential type E: Trait;
const AnotherConst: i32 = 100;
fn foo8() {println!("hello, world");}
const AnyConst10: i32 = 100;
const AnyConst2: i32 = 100;
}
2 changes: 2 additions & 0 deletions tests/target/issue-2863.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ impl<T> IntoIterator for SafeVec<T> {
existential type F: Trait;

const AnotherConst: i32 = 100;
const AnyConst2: i32 = 100;
const AnyConst10: i32 = 100;
const SomeConst: i32 = 100;

// comment on foo()
Expand Down

0 comments on commit 656d901

Please sign in to comment.