Print space after formal generic params in fn type by dtolnay · Pull Request #92372 · rust-lang/rust (original) (raw)
Follow-up to #92238 fixing one of the FIXMEs.
macro_rules! repro { ($ty:ty) => { stringify!($ty) }; }
fn main() { println!("{}", repro!(for<'a> fn(&'a u8))); }
Before: for<'a>fn(&'a u8)
After: for<'a> fn(&'a u8)
The pretty printer's print_formal_generic_params
already prints formal generic params correctly with a space, we just need to call it when printing BareFn types instead of reimplementing the printing incorrectly without a space.
fn print_formal_generic_params(&mut self, generic_params: &[ast::GenericParam]) { |
---|
if !generic_params.is_empty() { |
self.word("for"); |
self.print_generic_params(generic_params); |
self.nbsp(); |
} |
} |