about summary refs log tree commit diff
path: root/src/libsyntax/print/pp.rs
AgeCommit message (Collapse)AuthorLines
2020-02-01syntax::print -> new crate rustc_ast_prettyMazdak Farrokhzad-640/+0
2019-12-22Format the worldMark Rousskov-61/+40
2019-07-10Move pp::Printer helpers to direct implMark Rousskov-3/+3
2019-07-10Rename is_bol -> is_beginning_of_lineMark Rousskov-1/+5
Also moves it to pp::Printer from PrintState.
2019-07-10Drop length from Token::StringMark Rousskov-11/+14
It was always set to the string's length
2019-07-10Rename pretty_print_* to scan_* to follow naming in the paperMark Rousskov-11/+11
This is also easier to understand because the scan and print "tasks" are separate, but previously were both called "print" or "pretty print."
2019-07-10Simplify print_endMark Rousskov-3/+1
Presumably the code was from an older age of Rust and can now be written much simpler.
2019-07-10Simplify check_stack implementationMark Rousskov-7/+7
2019-07-10Move BufEntry assignment into scan_pushMark Rousskov-12/+7
2019-07-10Remove useless call to indentMark Rousskov-1/+0
2019-07-10Fully privatize (vs. crate visibility) functionsMark Rousskov-18/+18
2019-07-10Move pp::Printer out field to owned StringMark Rousskov-7/+8
This enforces that eof() must be called to get the String out, and generally is better from an API perspective. No users of pretty printing pre-allocate the buffer.
2019-06-29Remove io::Result from syntax::printMark Rousskov-51/+34
Since we're now writing directly to the vector, there's no need to thread results through the whole printing infrastructure
2019-06-29Replace pretty-printer Box<dyn Write> with &mut StringMark Rousskov-19/+12
2019-06-29Delete now-unused methodsMark Rousskov-4/+0
2019-06-29Privatize a bunch of methodsMark Rousskov-24/+24
2019-06-26Fix clippy::print_with_newlineIgor Matuszewski-1/+1
2019-04-01Optimize indentation in the pretty printer.Nicholas Nethercote-3/+19
Currently the pretty-printer calls `write!` for every space of indentation. On some workloads the indentation level can exceed 100, and a faster implementation reduces instruction counts by up to 7% on a few workloads.
2019-02-10rustc: doc commentsAlexander Regueiro-2/+2
2019-02-07libsyntax => 2018Taiki Endo-1/+2
2018-12-25Remove licensesMark Rousskov-10/+0
2018-12-07Various minor/cosmetic improvements to codeAlexander Regueiro-1/+1
2018-11-29Split up `pretty_print` and `print`.Nicholas Nethercote-150/+152
`pretty_print` takes a `Token` and `match`es on it. But the particular `Token` kind is known at each call site, so this commit splits it into five functions: `pretty_print_eof`, `pretty_print_begin`, etc. This commit also does likewise with `print`, though there is one callsite for `print` where the `Token` kind isn't known, so a generic `print` has to stay (but it now just calls out to the various `print_*` functions).
2018-11-29Use `Cow` in `Token::String`.Nicholas Nethercote-3/+9
`Printer::word` takes a `&str` and converts it into a `String`, which causes an allocation. But that allocation is rarely necessary, because `&str` is almost always a `&'static str` or a `String` that won't be used again. This commit changes `Token::String` so it holds a `Cow<'static, str>` instead of a `String`, which avoids a lot of allocations.
2018-11-29Remove `huge_word` and `zero_word`.Nicholas Nethercote-9/+16
They are unused. The commit also adds some blank lines between some methods.
2018-11-29Fix whitespace in `pp.rs`.Nicholas Nethercote-126/+126
This commit converts some 2-space indents to 4-space indents.
2018-07-10Deny bare trait objects in in src/libsyntaxljedrz-2/+2
2018-04-30Extend Printer::buf on demand.Nicholas Nethercote-7/+23
So that 55 entries (at 48 bytes each) don't need to be eagerly initialized on creation. This speeds up numerous rust-perf benchmark runs, by up to 3%.
2017-08-15use field init shorthand EVERYWHEREZack M. Davis-1/+1
Like #43008 (f668999), but _much more aggressive_.
2017-07-11Refactor methods onto Printer struct.Mark Simulacrum-56/+56
No (intentional) changes to behavior. This is intended to avoid the anti-pattern of having to import individual methods throughout code.
2017-06-23Removed as many "```ignore" as possible.kennytm-1/+1
Replaced by adding extra imports, adding hidden code (`# ...`), modifying examples to be runnable (sorry Homura), specifying non-Rust code, and converting to should_panic, no_run, or compile_fail. Remaining "```ignore"s received an explanation why they are being ignored.
2017-05-12Fix some clippy warnings in libsyntaxAndre Bogus-6/+6
This is mostly removing stray ampersands, needless returns and lifetimes.
2017-02-06A few documentation improvements for `syntax::print::pp`bjorn3-78/+89
* Moved algorithm explanation to module docs * Added ``` before and after the examples * Explanation of the `rbox`, `ibox` and `cbox` names * Added docs about the breaking types to `Breaks`
2016-10-10Merge `Printer::token` and `Printer::size`.Nicholas Nethercote-38/+31
Logically, it's a vector of pairs, so might as well represent it that way. The commit also changes `scan_stack` so that it is initialized with the default size, instead of the excessive `55 * linewidth` size, which it usually doesn't get even close to reaching.
2016-05-28Prevent overflows by increasing ring buffer sizeSebastian Thiel-2/+2
Please note that this change is just done to prevent issues as currently seen by syntex_syntax in future. See https://github.com/serde-rs/syntex/pull/47 for details. As shown in https://github.com/serde-rs/syntex/issues/33, complex code can easily overflow the ring-buffer and cause an assertion error.
2016-05-01libsyntax/pp: replace manual ring buffer with a VecDequeGeorg Brandl-52/+19
2016-05-01libsyntax/pp: minor modernizationsGeorg Brandl-40/+32
* implement Display on Token instead of custom tok_str() fn * use expression returns * remove redundant parens in asserts * remove "/* bad */" comments that appear to be related to early changes in memory management * and a few individual idiomatic changes
2016-03-22try! -> ?Jorge Aparicio-5/+5
Automated conversion using the untry tool [1] and the following command: ``` $ find -name '*.rs' -type f | xargs untry ``` at the root of the Rust repo. [1]: https://github.com/japaric/untry
2016-03-12Removed integer suffixes in libsyntax cratesrinivasreddy-2/+2
2015-11-12libsyntax: deny warnings in doctestsKevin Butler-2/+4
2015-07-09Use vec![elt; n] where possibleUlrik Sverdrup-4/+3
The common pattern `iter::repeat(elt).take(n).collect::<Vec<_>>()` is exactly equivalent to `vec![elt; n]`, do this replacement in the whole tree. (Actually, vec![] is smart enough to only call clone n - 1 times, while the former solution would call clone n times, and this fact is virtually irrelevant in practice.)
2015-05-03Update old uses of ~ in comments and debugging statementsCarol Nichols-9/+9
2015-04-21syntax: Replace String::from_str with the stable String::fromErick Tryzelaar-1/+1
2015-04-14Negative case of `len()` -> `is_empty()`Tamir Duberstein-1/+1
`s/([^\(\s]+\.)len\(\) [(?:!=)>] 0/!$1is_empty()/g`
2015-04-01Fallout in libsyntaxNiko Matsakis-2/+2
2015-03-04std: Deprecate std::old_io::fsAlex Crichton-24/+24
This commit deprecates the majority of std::old_io::fs in favor of std::fs and its new functionality. Some functions remain non-deprecated but are now behind a feature gate called `old_fs`. These functions will be deprecated once suitable replacements have been implemented. The compiler has been migrated to new `std::fs` and `std::path` APIs where appropriate as part of this change.
2015-03-02Use `const`s instead of `static`s where appropriateFlorian Zeitz-1/+1
This changes the type of some public constants/statics in libunicode. Notably some `&'static &'static [(char, char)]` have changed to `&'static [(char, char)]`. The regexp crate seems to be the sole user of these, yet this is technically a [breaking-change]
2015-02-20Remove remaining uses of `[]`. This time I tried to use deref coercions ↵Niko Matsakis-1/+1
where possible.
2015-02-18Round 3 test fixes and conflictsAlex Crichton-2/+2
2015-02-18rollup merge of #22502: nikomatsakis/deprecate-bracket-bracketAlex Crichton-1/+1
Conflicts: src/libcollections/slice.rs src/libcollections/str.rs src/librustc/middle/lang_items.rs src/librustc_back/rpath.rs src/librustc_typeck/check/regionck.rs src/libstd/ffi/os_str.rs src/libsyntax/diagnostic.rs src/libsyntax/parse/parser.rs src/libsyntax/util/interner.rs src/test/run-pass/regions-refcell.rs