about summary refs log tree commit diff
path: root/compiler/rustc_ast_pretty
AgeCommit message (Collapse)AuthorLines
2022-01-18Eliminate a check_stack call on an empty scan stackDavid Tolnay-1/+1
2022-01-18Index a single time in check_stackDavid Tolnay-4/+5
2022-01-18Implement check_stack nonrecursivelyDavid Tolnay-9/+10
2022-01-18Implement check_stream nonrecursivelyDavid Tolnay-3/+3
2022-01-18Replace `if` + `unwrap` with `if let` in check_stackDavid Tolnay-2/+1
2022-01-18Ensure Printer buf is always indexed using self.left or self.rightDavid Tolnay-3/+3
2022-01-18Inline Printer's scan_pop_bottom methodDavid Tolnay-5/+1
2022-01-18Inline Printer's scan_top methodDavid Tolnay-5/+1
2022-01-18Inline Printer's scan_pop methodDavid Tolnay-7/+3
2022-01-18Simplify ring buffer pushesDavid Tolnay-7/+12
2022-01-18Inline Printer's scan_push methodDavid Tolnay-8/+6
2022-01-18Inline Printer's advance_right methodDavid Tolnay-9/+8
2022-01-18Move item-related pretty printing functions to moduleDavid Tolnay-636/+646
2022-01-18Move expr-related pretty printing functions to moduleDavid Tolnay-564/+574
2022-01-18Delete pretty printer tracingDavid Tolnay-53/+0
2022-01-18Render more readable macro matchers in rustdocDavid Tolnay-1/+1
2022-01-18Auto merge of #87648 - JulianKnodt:const_eq_constrain, r=oli-obkbors-7/+8
allow eq constraints on associated constants Updates #70256 (cc `@varkor,` `@Centril)`
2022-01-17Abstract the pretty printer's ringbuffer to be infinitely sizedDavid Tolnay-22/+67
2022-01-17Use Term in ProjectionPredicatekadmin-3/+1
ProjectionPredicate should be able to handle both associated types and consts so this adds the first step of that. It mainly just pipes types all the way down, not entirely sure how to handle consts, but hopefully that'll come with time.
2022-01-17Add termkadmin-7/+6
Instead of having a separate enum variant for types and consts have one but have either a const or type.
2022-01-17add eq constraints on associated constantskadmin-3/+7
2022-01-17Auto merge of #92816 - tmiasko:rm-llvm-asm, r=Amanieubors-56/+0
Remove deprecated LLVM-style inline assembly The `llvm_asm!` was deprecated back in #87590 1.56.0, with intention to remove it once `asm!` was stabilized, which already happened in #91728 1.59.0. Now it is time to remove `llvm_asm!` to avoid continued maintenance cost. Closes #70173. Closes #92794. Closes #87612. Closes #82065. cc `@rust-lang/wg-inline-asm` r? `@Amanieu`
2022-01-17Rollup merge of #92921 - dtolnay:printernew, r=wesleywiserMatthias Krüger-25/+25
Rename Printer constructor from mk_printer() to Printer::new() The original naming is left over from 2011 which was before impl blocks and associated functions existed. https://github.com/rust-lang/rust/blob/21313d623a505086b2973f30c19db4f1d6ec8f61/src/comp/pretty/pp.rs
2022-01-16Rollup merge of #92487 - dtolnay:traitalias, r=matthewjasperMatthias Krüger-3/+3
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-14Rename Printer constructor from mk_printer() to Printer::new()David Tolnay-25/+25
2022-01-12Remove deprecated LLVM-style inline assemblyTomasz Miąsko-56/+0
2022-01-07Rollup merge of #92336 - dtolnay:printstateself, r=michaelwoeristerEric Huss-24/+24
Remove &self from PrintState::to_string The point of `PrintState::to_string` is to create a `State` and evaluate the caller's closure on it: https://github.com/rust-lang/rust/blob/e9fbe79292783972a222afd270db3f77c0b4f3c8/compiler/rustc_ast_pretty/src/pprust/state.rs#L868-L872 Making the caller *also* construct and pass in a `State`, which is then ignored, was confusing.
2022-01-06Rollup merge of #92417 - dtolnay:printimpl, r=jackh726Matthias Krüger-3/+6
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-2/+8
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-3/+3
2022-01-01Rollup merge of #92420 - dtolnay:patrange, r=Mark-SimulacrumMatthias Krüger-1/+0
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/+0
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-1/+0
2021-12-29Fix spacing in pretty printed PatKind::Struct with no fieldsDavid Tolnay-2/+8
2021-12-29Move equal sign back into head iboxDavid Tolnay-1/+3
2021-12-29Fix spacing of pretty printed const item without bodyDavid Tolnay-1/+1
2021-12-29Fix spacing and ordering of words in pretty printed ImplDavid Tolnay-3/+6
2021-12-29Fix double space in pretty printed TryBlockDavid Tolnay-1/+0
2021-12-29Rollup merge of #92372 - dtolnay:fntype, r=jackh726Matthias Krüger-4/+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-29Rollup merge of #92371 - dtolnay:attrblock, r=oli-obkMatthias Krüger-11/+12
Remove pretty printer space inside block with only outer attrs Follow-up to #92238 fixing one of the FIXMEs. ```rust macro_rules! repro { ($expr:expr) => { stringify!($expr) }; } fn main() { println!("{}", repro!(#[attr] {})); } ``` Before:&ensp;`#[attr] { }` After:&ensp;`#[attr] {}`
2021-12-28Print space after formal generic params in fn typeDavid Tolnay-4/+1
2021-12-28Remove pretty printer space inside block with only outer attrsDavid Tolnay-11/+12
2021-12-28Parse and suggest moving where clauses after equals for type aliasesJack Huey-28/+28
2021-12-27Remove &self from PrintState::to_stringDavid Tolnay-24/+24
2021-12-15Remove unnecessary sigils around `Symbol::as_str()` calls.Nicholas Nethercote-2/+2
2021-12-10Rollup merge of #91625 - est31:remove_indexes, r=oli-obkMatthias Krüger-14/+14
Remove redundant [..]s
2021-12-09Remove redundant [..]sest31-14/+14
2021-12-08Pretty print break and continue without redundant spaceDavid Tolnay-5/+3
2021-12-07Remove unneeded access to pretty printer's `s` field in favor of derefDavid Tolnay-165/+165
2021-12-07Rollup merge of #91562 - dtolnay:asyncspace, r=Mark-SimulacrumMatthias Krüger-1/+0
Pretty print async block without redundant space **Repro:** ```rust macro_rules! m { ($e:expr) => { stringify!($e) }; } fn main() { println!("{:?}", m!(async {})); } ``` **Before:** <code>"async&nbsp;&nbsp;{}"</code> **After:** `"async {}"` <br> In this function: https://github.com/rust-lang/rust/blob/65c55bf931a55e6b1e5ed14ad8623814a7386424/compiler/rustc_ast_pretty/src/pprust/state.rs#L2049-L2051 the `print_capture_clause` and `word_nbsp`/`word_space` calls already put a space after the `async` and `move` keywords being printed. The extra `self.s.space()` call removed by this PR resulted in the redundant double space. https://github.com/rust-lang/rust/blob/65c55bf931a55e6b1e5ed14ad8623814a7386424/compiler/rustc_ast_pretty/src/pprust/state.rs#L2640-L2645 https://github.com/rust-lang/rust/blob/65c55bf931a55e6b1e5ed14ad8623814a7386424/compiler/rustc_ast_pretty/src/helpers.rs#L34-L37 https://github.com/rust-lang/rust/blob/65c55bf931a55e6b1e5ed14ad8623814a7386424/compiler/rustc_ast_pretty/src/helpers.rs#L5-L8