Fix spacing and ordering of words in pretty printed Impl

This commit is contained in:
David Tolnay 2021-12-29 12:10:24 -08:00
parent f3df63f8ee
commit a24e238bdf
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82
2 changed files with 8 additions and 5 deletions

View File

@ -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("!");
}

View File

@ -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!(
@ -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!(