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
Vadim Petrochenkov
25b05147b3
syntax: Remove Deref impl from Token
2019-06-08 22:38:23 +03:00
Vadim Petrochenkov
2af47facc3
syntax: Treat error literals in more principled way
2019-06-07 18:01:50 +03:00
Vadim Petrochenkov
e0127dbf81
syntax: Use Token in TokenTree::Token
2019-06-06 14:03:15 +03:00
Vadim Petrochenkov
99b27d749c
syntax: Rename Token into TokenKind
2019-06-06 14:03:14 +03:00
Alexander Regueiro
3816958f18
Implemented for function bounds, type bounds, and named existential types.
2019-06-05 21:09:26 +01:00
Alexander Regueiro
35585c499f
Aggregation of drive-by cosmetic changes.
2019-06-05 21:09:26 +01:00
Eduard-Mihai Burtescu
d0c78dd7aa
syntax: revert ast::AsyncArgument and associated changes.
...
Here follows the main reverts applied in order to make this commit:
Revert "Rollup merge of #60676 - davidtwco:issue-60674, r=cramertj"
This reverts commit 45b09453db , reversing
changes made to f6df1f6c30 .
Revert "Rollup merge of #60437 - davidtwco:issue-60236, r=nikomatsakis"
This reverts commit 16939a50ea , reversing
changes made to 12bf981552 .
Revert "Rollup merge of #59823 - davidtwco:issue-54716, r=cramertj"
This reverts commit 62d1574876 , reversing
changes made to 4eff8526a7 .
2019-06-03 10:20:35 +01:00
varkor
7948b68d02
Remove ObsoleteInPlace
2019-05-24 01:27:32 +01:00
Vadim Petrochenkov
90d15e7704
syntax: Some code cleanup
2019-05-23 12:46:41 +03:00
Vadim Petrochenkov
ca2a50fad7
syntax: Turn token::Lit into a struct
2019-05-23 12:46:24 +03:00
Vadim Petrochenkov
59a382122f
Simplify use of keyword symbols
2019-05-22 19:48:56 +03:00
John Kåre Alsaker
a1f2dceaeb
Move edition outside the hygiene lock and avoid accessing it
2019-05-21 18:17:05 +02:00
Nicholas Nethercote
86cc326d06
Avoid unnecessary interning in Ident::from_str() calls.
...
A lot of these static symbols are pre-interned.
2019-05-17 20:10:50 +10:00
bors
4443957f27
Auto merge of #60767 - Centril:rollup-4cbsb73, r=Centril
...
Rollup of 4 pull requests
Successful merges:
- #60694 (Fix HIR printing of existential type #60662 )
- #60750 (syntax: Remove some legacy nonterminal tokens)
- #60751 (Assorted cleanup in parser & AST validation)
- #60752 (Fix minor typos for ItemLocalId)
Failed merges:
r? @ghost
2019-05-12 20:28:19 +00:00
Vadim Petrochenkov
14b353820f
syntax: Remove some legacy nonterminal tokens
2019-05-12 02:01:56 +03:00
Vadim Petrochenkov
8739668438
Simplify conversions between tokens and semantic literals
2019-05-11 14:24:21 +03:00