diff --git a/src/items.rs b/src/items.rs index bdae2eaafc6..33d71180f34 100644 --- a/src/items.rs +++ b/src/items.rs @@ -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}; @@ -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, diff --git a/tests/source/issue-2863.rs b/tests/source/issue-2863.rs index 792ffdbac24..3c83e13a090 100644 --- a/tests/source/issue-2863.rs +++ b/tests/source/issue-2863.rs @@ -22,4 +22,6 @@ impl IntoIterator for SafeVec { existential type E: Trait; const AnotherConst: i32 = 100; fn foo8() {println!("hello, world");} + const AnyConst10: i32 = 100; + const AnyConst2: i32 = 100; } diff --git a/tests/target/issue-2863.rs b/tests/target/issue-2863.rs index a53628e3ea9..bfe16565649 100644 --- a/tests/target/issue-2863.rs +++ b/tests/target/issue-2863.rs @@ -13,6 +13,8 @@ impl IntoIterator for SafeVec { existential type F: Trait; const AnotherConst: i32 = 100; + const AnyConst2: i32 = 100; + const AnyConst10: i32 = 100; const SomeConst: i32 = 100; // comment on foo()