Skip to content

Commit

Permalink
Fix spacing and ordering of words in pretty printed Impl
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Dec 29, 2021
1 parent f3df63f commit a24e238
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
9 changes: 6 additions & 3 deletions compiler/rustc_ast_pretty/src/pprust/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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("!");
}
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/macros/stringify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ fn test_item() {
stringify_item!(
impl<T> Struct<T> {}
),
"impl <T> Struct<T> {}", // FIXME
"impl<T> Struct<T> {}",
);
assert_eq!(
stringify_item!(
Expand All @@ -615,7 +615,7 @@ fn test_item() {
stringify_item!(
impl<T> const Trait for T {}
),
"impl const <T> Trait for T {}", // FIXME
"impl<T> const Trait for T {}",
);
assert_eq!(
stringify_item!(
Expand Down

0 comments on commit a24e238

Please sign in to comment.