Rollup merge of #92417 - dtolnay:printimpl, r=jackh726
Fix spacing and ordering of words in pretty printed Impl Follow-up to #92238 fixing one of the FIXMEs. ```rust macro_rules! repro { ($item:item) => { stringify!($item) }; } fn main() { println!("{}", repro!(impl<T> Struct<T> {})); println!("{}", repro!(impl<T> const Trait for T {})); } ``` Before: `impl <T> Struct<T> {}` After: `impl<T> Struct<T> {}` Before: `impl const <T> Trait for T {}` 😿 After: `impl<T> const Trait for T {}`
This commit is contained in:
commit
1a8f69826c
@ -1287,14 +1287,17 @@ impl<'a> State<'a> {
|
|||||||
self.print_visibility(&item.vis);
|
self.print_visibility(&item.vis);
|
||||||
self.print_defaultness(defaultness);
|
self.print_defaultness(defaultness);
|
||||||
self.print_unsafety(unsafety);
|
self.print_unsafety(unsafety);
|
||||||
self.word_nbsp("impl");
|
self.word("impl");
|
||||||
self.print_constness(constness);
|
|
||||||
|
|
||||||
if !generics.params.is_empty() {
|
if generics.params.is_empty() {
|
||||||
|
self.nbsp();
|
||||||
|
} else {
|
||||||
self.print_generic_params(&generics.params);
|
self.print_generic_params(&generics.params);
|
||||||
self.space();
|
self.space();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.print_constness(constness);
|
||||||
|
|
||||||
if let ast::ImplPolarity::Negative(_) = polarity {
|
if let ast::ImplPolarity::Negative(_) = polarity {
|
||||||
self.word("!");
|
self.word("!");
|
||||||
}
|
}
|
||||||
|
@ -603,7 +603,7 @@ fn test_item() {
|
|||||||
stringify_item!(
|
stringify_item!(
|
||||||
impl<T> Struct<T> {}
|
impl<T> Struct<T> {}
|
||||||
),
|
),
|
||||||
"impl <T> Struct<T> {}", // FIXME
|
"impl<T> Struct<T> {}",
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
stringify_item!(
|
stringify_item!(
|
||||||
@ -611,6 +611,12 @@ fn test_item() {
|
|||||||
),
|
),
|
||||||
"pub impl Trait for Struct {}",
|
"pub impl Trait for Struct {}",
|
||||||
);
|
);
|
||||||
|
assert_eq!(
|
||||||
|
stringify_item!(
|
||||||
|
impl<T> const Trait for T {}
|
||||||
|
),
|
||||||
|
"impl<T> const Trait for T {}",
|
||||||
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
stringify_item!(
|
stringify_item!(
|
||||||
impl ~const Struct {}
|
impl ~const Struct {}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user