diff --git a/src/items.rs b/src/items.rs index 6fb69d6b883..b57be8c1054 100644 --- a/src/items.rs +++ b/src/items.rs @@ -728,7 +728,9 @@ fn visit_impl_items(&mut self, items: &[ptr::P]) { (Const(..), Const(..)) | (MacCall(..), MacCall(..)) => { a.ident.as_str().cmp(b.ident.as_str()) } - (Fn(..), Fn(..)) => a.span.lo().cmp(&b.span.lo()), + (Fn(..), Fn(..)) | (Delegation(..), Delegation(..)) => { + a.span.lo().cmp(&b.span.lo()) + } (Type(ty), _) if is_type(&ty.ty) => Ordering::Less, (_, Type(ty)) if is_type(&ty.ty) => Ordering::Greater, (Type(..), _) => Ordering::Less, @@ -737,6 +739,8 @@ fn visit_impl_items(&mut self, items: &[ptr::P]) { (_, Const(..)) => Ordering::Greater, (MacCall(..), _) => Ordering::Less, (_, MacCall(..)) => Ordering::Greater, + (Delegation(..), _) => Ordering::Less, + (_, Delegation(..)) => Ordering::Greater, }); let mut prev_kind = None; for (buf, item) in buffer { diff --git a/src/visitor.rs b/src/visitor.rs index f4d84d1381f..bc5accefd92 100644 --- a/src/visitor.rs +++ b/src/visitor.rs @@ -592,6 +592,11 @@ pub(crate) fn visit_item(&mut self, item: &ast::Item) { ); self.push_rewrite(item.span, rewrite); } + ast::ItemKind::Delegation(..) => { + // TODO: rewrite delegation items once syntax is established. + // For now, leave the contents of the Span unformatted. + self.push_rewrite(item.span, None) + } }; } self.skip_context = skip_context_saved;