Vadim Petrochenkov
160c40bc88
pprust: Remove the box from print_tts
...
Wrap the whole attribute into a box instead
2019-07-15 12:42:07 +03:00
Vadim Petrochenkov
11585b598c
pprust: Use print_mac_common for delimited token groups
2019-07-15 12:42:07 +03:00
Vadim Petrochenkov
23c5c1bfe7
pprust: Use print_mac_common for attributes
2019-07-15 12:42:07 +03:00
Vadim Petrochenkov
500b00127b
pprust: Use print_mac_common for macro_rules definitions
2019-07-15 12:42:07 +03:00
Vadim Petrochenkov
65a714a6a0
pprust: Move some methods to the PrintState trait
...
So that path and macro argument printing code can be shared
2019-07-15 12:42:07 +03:00
Esteban Küber
726aa1437f
Use snippet instead of pprinting statement
2019-07-12 14:01:13 -07:00
Vadim Petrochenkov
e38106599a
Address review comments
2019-07-11 12:34:57 +03:00
Vadim Petrochenkov
af26e7f4f4
pretty-print: Merge print_tts and print_tts_ext
2019-07-11 12:08:29 +03:00
Vadim Petrochenkov
da50d59881
pretty-print: Do not lose the $crate printing flag in print_tt
2019-07-11 12:07:35 +03:00
Mark Rousskov
56a9237b59
File is now short enough for tidy
2019-07-10 07:13:59 -04:00
Mark Rousskov
096cb4137d
Remove writer function from PrintState
2019-07-10 07:13:57 -04:00
Mark Rousskov
73c1752b8e
Use constant instead of magic number
2019-07-10 07:13:22 -04:00
Mark Rousskov
63fdf1a527
Remove needless indent arguments
...
We're always indenting by INDENT_UNIT anyway
2019-07-10 07:13:22 -04:00
Mark Rousskov
cab453250a
Move pp::Printer helpers to direct impl
2019-07-10 07:13:20 -04:00
Mark Rousskov
e91dbc5916
Rename is_bol -> is_beginning_of_line
...
Also moves it to pp::Printer from PrintState.
2019-07-10 07:12:29 -04:00
Mark Rousskov
39aa9bf730
Remove needless indirection in bclose
2019-07-10 07:12:29 -04:00
Mark Rousskov
04b80a5f5d
Drop length from Token::String
...
It was always set to the string's length
2019-07-10 07:12:29 -04:00
Mark Rousskov
5879146392
Rename pretty_print_* to scan_* to follow naming in the paper
...
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-10 07:12:29 -04:00
Mark Rousskov
4783d9eaa5
Remove is_begin/is_end functions from PrintState
...
These are somewhat ambiguous (beginning/end of what?) so it's better to
inline their one use into the code.
2019-07-10 07:12:29 -04:00
Mark Rousskov
57cf7a2e57
Simplify print_end
...
Presumably the code was from an older age of Rust and can now be written
much simpler.
2019-07-10 07:12:29 -04:00
Mark Rousskov
55a6a761b9
Simplify check_stack implementation
2019-07-10 07:12:29 -04:00
Mark Rousskov
cd2d8326a5
Move BufEntry assignment into scan_push
2019-07-10 07:12:28 -04:00
Mark Rousskov
ccf279d9c3
Remove useless call to indent
2019-07-10 07:12:28 -04:00
Mark Rousskov
4c58fc32ae
Fully privatize (vs. crate visibility) functions
2019-07-10 07:12:28 -04:00
Mark Rousskov
00ca508608
Move pp::Printer out field to owned String
...
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-07-10 07:12:28 -04:00
Mark Rousskov
e0ffa7c3d2
Inline State::new_from_input in pprust
...
This function took too many arguments and are simple on the inside;
inlining them makes complexity go down.
hir::print's copy is unfortunately used from librustc_driver so inlining
it is not as straightforward.
2019-07-10 07:12:28 -04:00
Mark Rousskov
e0db2e606c
print_crate returns String instead of taking an out pointer
2019-07-10 07:12:28 -04:00
Mark Rousskov
7e3791469f
Replace src: &mut dyn Read with String
2019-07-10 07:12:28 -04:00
Mark Rousskov
0eb2e566c1
Combine comment-handling logic into struct
...
This also permits sharing the underlying code between pprust and
hir::print.
2019-07-10 07:12:28 -04:00
Mark Rousskov
9b5e39723d
Inline State::new
...
There was only one callsite for each and this removes the
unwrap_or_default's on the comments argument
2019-07-10 07:12:28 -04:00
Mark Rousskov
59b161c7c8
Stop Option-wrapping comments
...
We always check against the length before indexing anyway.
2019-07-10 07:12:28 -04:00
Mark Rousskov
a573d143a2
Remove unused boxes vector
2019-07-10 07:12:28 -04:00
Mark Rousskov
4483980285
Privatize and remove unused functions
2019-07-10 07:12:26 -04:00
Mark Rousskov
11d521676f
Move lifetime_to_string to Display impl
2019-07-10 07:11:29 -04:00
Mark Rousskov
a440337e2b
Remove unused arm_to_string
2019-07-10 07:11:29 -04:00
Mark Rousskov
0f10d114e4
Remove duplicate attr_to_string
...
attribute_to_string exists.
2019-07-10 07:11:29 -04:00
Mark Rousskov
9b0ebfa4e9
Move literal_to_string to fmt::Display
2019-07-10 07:11:29 -04:00
Vadim Petrochenkov
4344a90308
Pretty-print $crate as crate/::my_crate in tokens
...
...but only if those tokens are printed from inside of AST pretty-printing.
2019-07-09 22:17:44 +03:00
Mark Rousskov
d26c4b7bd6
Inline rust_printer
2019-06-29 09:10:17 -04:00
Mark Rousskov
ff27756a1c
Remove unused import
2019-06-29 09:10:17 -04:00
Mark Rousskov
da5c835c8b
Remove io::Result from syntax::print
...
Since we're now writing directly to the vector, there's no need to
thread results through the whole printing infrastructure
2019-06-29 09:10:17 -04:00
Mark Rousskov
1aff8af213
Replace pretty-printer Box<dyn Write> with &mut String
2019-06-29 09:10:15 -04:00
Mark Rousskov
209bde16c5
Delete now-unused methods
2019-06-29 09:09:32 -04:00
Mark Rousskov
e2d7df5067
Privatize a bunch of methods
2019-06-29 09:09:31 -04:00
Igor Matuszewski
1af1f6277e
Fix clippy::print_with_newline
2019-06-26 14:11:58 +02:00
bors
3cc3486733
Auto merge of #62075 - Centril:guardless-match-arms, r=petrochenkov
...
Remove `ast::Guard`
With the introduction of `ast::ExprKind::Let` in https://github.com/rust-lang/rust/pull/60861 , the `ast::Guard` structure is now redundant in terms of representing [`if let` guards](https://github.com/rust-lang/rust/issues/51114 ) in AST since it can be represented by `ExprKind::Let` syntactically. Therefore, we remove `ast::Guard` here.
However, we keep `hir::Guard` because the semantic representation is a different matter and this story is more unclear right now (might involve `goto 'arm` in HIR or something...).
r? @petrochenkov
2019-06-24 05:00:10 +00:00
Mazdak Farrokhzad
4d53714183
Remove redundant syntax::ast::Guard.
2019-06-23 11:32:16 +02:00
Mazdak Farrokhzad
851066f57e
let_chains: Fix bugs in pretty printing.
2019-06-23 01:29:29 +02:00
Mazdak Farrokhzad
3fc9642014
let_chains: Handle it in AST pretty printing.
2019-06-23 01:29:29 +02:00
Matthew Jasper
63edd2c358
Remove the HirId/NodeId from where clauses
...
Also give them a span in the HIR
2019-06-18 22:54:51 +01:00