about summary refs log tree commit diff
path: root/src/libsyntax/print/pp.rs
AgeCommit message (Collapse)AuthorLines
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
2015-02-18Replace all uses of `&foo[]` with `&foo[..]` en masse.Niko Matsakis-1/+1
2015-02-18Remove `i`, `is`, `u`, or `us` suffixes that are not necessary.Niko Matsakis-1/+1
2015-02-02Omit integer suffix when unnecessaryAlfie John-16/+16
See PR # 21378 for context
2015-01-31Kill more `isize`sTobias Bucher-1/+1
2015-01-26Fallout of io => old_ioAlex Crichton-22/+22
2015-01-18libsyntax: 0u -> 0us, 0i -> 0isPaul Collier-17/+17
2015-01-18libsyntax: int types -> isizePaul Collier-25/+25
2015-01-17libsyntax: uint types to usizePaul Collier-23/+23
2015-01-13syntax: Rewrite pp advance_left to use a constant stack sizeErick Tryzelaar-31/+37
2015-01-13syntax: Don't import the pp.rs enum variants into the namespaceErick Tryzelaar-63/+68
2015-01-07use slicing sugarJorge Aparicio-3/+3
2015-01-07Replace full slice notation with index callsNick Cameron-2/+2
2015-01-03sed -i -s 's/#\[deriving(/#\[derive(/g' **/*.rsJorge Aparicio-6/+6
2014-12-30Fallout from stabilizationAaron Turon-3/+4
2014-12-21Fallout of std::str stabilizationAlex Crichton-3/+3
2014-12-19libsyntax: use `#[deriving(Copy)]`Jorge Aparicio-13/+5
2014-12-08librustc: Make `Copy` opt-in.Niko Matsakis-0/+10
This change makes the compiler no longer infer whether types (structures and enumerations) implement the `Copy` trait (and thus are implicitly copyable). Rather, you must implement `Copy` yourself via `impl Copy for MyType {}`. A new warning has been added, `missing_copy_implementations`, to warn you if a non-generic public type has been added that could have implemented `Copy` but didn't. For convenience, you may *temporarily* opt out of this behavior by using `#![feature(opt_out_copy)]`. Note though that this feature gate will never be accepted and will be removed by the time that 1.0 is released, so you should transition your code away from using it. This breaks code like: #[deriving(Show)] struct Point2D { x: int, y: int, } fn main() { let mypoint = Point2D { x: 1, y: 1, }; let otherpoint = mypoint; println!("{}{}", mypoint, otherpoint); } Change this code to: #[deriving(Show)] struct Point2D { x: int, y: int, } impl Copy for Point2D {} fn main() { let mypoint = Point2D { x: 1, y: 1, }; let otherpoint = mypoint; println!("{}{}", mypoint, otherpoint); } This is the backwards-incompatible part of #13231. Part of RFC #3. [breaking-change]