summary refs log tree commit diff
path: root/src/test/ui/macros/stringify.rs
AgeCommit message (Collapse)AuthorLines
2022-02-03Bless all pretty printer tests and ui testsDavid Tolnay-10/+10
2022-01-16Rollup merge of #92487 - dtolnay:traitalias, r=matthewjasperMatthias Krüger-1/+1
Fix unclosed boxes in pretty printing of TraitAlias This was causing trait aliases to not even render at all in stringified / pretty printed output. ```rust macro_rules! repro { ($item:item) => { stringify!($item) }; } fn main() { println!("{:?}", repro!(pub trait Trait<T> = Sized where T: 'a;)); } ``` Before:&ensp;`""` After:&ensp;`"pub trait Trait<T> = Sized where T: 'a;"` The fix is copied from how `head`/`end` for `ItemKind::Use`, `ItemKind::ExternCrate`, and `ItemKind::Mod` are all done in the pretty printer: https://github.com/rust-lang/rust/blob/dd3ac41495e85a9b7b5cb3186379d02ce17e51fe/compiler/rustc_ast_pretty/src/pprust/state.rs#L1178-L1184
2022-01-06Rollup merge of #92417 - dtolnay:printimpl, r=jackh726Matthias Krüger-1/+7
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:&ensp;`impl <T> Struct<T> {}` After:&ensp;`impl<T> Struct<T> {}` Before:&ensp;`impl const <T> Trait for T {}` :crying_cat_face: After:&ensp;`impl<T> const Trait for T {}`
2022-01-03Rollup merge of #92418 - dtolnay:emptystructpat, r=michaelwoeristerMatthias Krüger-4/+4
Fix spacing in pretty printed PatKind::Struct with no fields Follow-up to #92238 fixing one of the FIXMEs. ```rust macro_rules! repro { ($pat:pat) => { stringify!($pat) }; } fn main() { println!("{}", repro!(Struct {})); } ``` Before:&ensp;<code>Struct&nbsp;{&nbsp;&nbsp;}</code> After:&ensp;<code>Struct&nbsp;{}</code>
2022-01-01Fix unclosed boxes in pretty printing of TraitAliasDavid Tolnay-1/+1
2022-01-01Rollup merge of #92420 - dtolnay:patrange, r=Mark-SimulacrumMatthias Krüger-4/+4
Fix whitespace in pretty printed PatKind::Range Follow-up to #92238 fixing one of the FIXMEs. ```rust macro_rules! repro { ($pat:pat) => { stringify!($pat) }; } fn main() { println!("{}", repro!(0..=1)); } ``` Before:&ensp;`0 ..=1` After:&ensp;`0..=1` The canonical spacing applied by rustfmt has no space after the lower expr. Rustc's parser diagnostics also do not put a space there: https://github.com/rust-lang/rust/blob/df96fb166f59431e3de443835e50d5b8a7a4adb0/compiler/rustc_parse/src/parser/pat.rs#L754
2022-01-01Rollup merge of #92412 - dtolnay:tryspace, r=Mark-SimulacrumMatthias Krüger-1/+1
Fix double space in pretty printed TryBlock Follow-up to #92238 fixing one of the FIXMEs. ```rust macro_rules! repro { ($expr:expr) => { stringify!($expr) }; } fn main() { println!("{}", repro!(try {})); } ``` Before:&ensp;<code>try&nbsp;&nbsp;{}</code> After:&ensp;<code>try&nbsp;{}</code> The `head` helper already appends a space: https://github.com/rust-lang/rust/blob/2b67c30bfece00357d5fc09d99b49f21066f04ba/compiler/rustc_ast_pretty/src/pprust/state.rs#L654-L664 so doing `head` followed by `space` resulted in a double space: https://github.com/rust-lang/rust/blob/2b67c30bfece00357d5fc09d99b49f21066f04ba/compiler/rustc_ast_pretty/src/pprust/state.rs#L2241-L2242
2021-12-29Fix whitespace in pretty printed PatKind::RangeDavid Tolnay-4/+4
2021-12-29Fix spacing in pretty printed PatKind::Struct with no fieldsDavid Tolnay-4/+4
2021-12-29Fix spacing of pretty printed const item without bodyDavid Tolnay-3/+3
2021-12-29Fix spacing and ordering of words in pretty printed ImplDavid Tolnay-2/+2
2021-12-29Add a pretty printer test of impl<T> const TraitDavid Tolnay-0/+6
2021-12-29Fix double space in pretty printed TryBlockDavid Tolnay-1/+1
2021-12-29Rollup merge of #92372 - dtolnay:fntype, r=jackh726Matthias Krüger-1/+1
Print space after formal generic params in fn type Follow-up to #92238 fixing one of the FIXMEs. ```rust macro_rules! repro { ($ty:ty) => { stringify!($ty) }; } fn main() { println!("{}", repro!(for<'a> fn(&'a u8))); } ``` Before:&ensp;`for<'a>fn(&'a u8)` After:&ensp;`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. https://github.com/rust-lang/rust/blob/83b15bfe1c15f325bc186ebfe3691b729ed59f2b/compiler/rustc_ast_pretty/src/pprust/state.rs#L1394-L1400
2021-12-28Print space after formal generic params in fn typeDavid Tolnay-1/+1
2021-12-28Remove pretty printer space inside block with only outer attrsDavid Tolnay-1/+1
2021-12-23Fix tidy line length lint in stringify testsDavid Tolnay-4/+16
2021-12-23Format with rust-lang/rust's rustfmt settingsDavid Tolnay-41/+14
2021-12-23Add a test suite for stringify macroDavid Tolnay-0/+894