From a24e238bdf07b2e59f5d3af376647742a6d7f05a Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Wed, 29 Dec 2021 12:10:24 -0800 Subject: [PATCH] Fix spacing and ordering of words in pretty printed Impl --- compiler/rustc_ast_pretty/src/pprust/state.rs | 9 ++++++--- src/test/ui/macros/stringify.rs | 4 ++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/compiler/rustc_ast_pretty/src/pprust/state.rs b/compiler/rustc_ast_pretty/src/pprust/state.rs index f0c1d017326..c2253e63356 100644 --- a/compiler/rustc_ast_pretty/src/pprust/state.rs +++ b/compiler/rustc_ast_pretty/src/pprust/state.rs @@ -1285,14 +1285,17 @@ impl<'a> State<'a> { self.print_visibility(&item.vis); self.print_defaultness(defaultness); self.print_unsafety(unsafety); - self.word_nbsp("impl"); - self.print_constness(constness); + self.word("impl"); - if !generics.params.is_empty() { + if generics.params.is_empty() { + self.nbsp(); + } else { self.print_generic_params(&generics.params); self.space(); } + self.print_constness(constness); + if let ast::ImplPolarity::Negative(_) = polarity { self.word("!"); } diff --git a/src/test/ui/macros/stringify.rs b/src/test/ui/macros/stringify.rs index 88305d22d77..e2f47e0af54 100644 --- a/src/test/ui/macros/stringify.rs +++ b/src/test/ui/macros/stringify.rs @@ -603,7 +603,7 @@ fn test_item() { stringify_item!( impl Struct {} ), - "impl Struct {}", // FIXME + "impl Struct {}", ); assert_eq!( stringify_item!( @@ -615,7 +615,7 @@ fn test_item() { stringify_item!( impl const Trait for T {} ), - "impl const Trait for T {}", // FIXME + "impl const Trait for T {}", ); assert_eq!( stringify_item!(