varkor
c28ce3e4ca
Replace "existential" by "opaque"
2019-08-02 02:44:36 +01:00
Mazdak Farrokhzad
758931948f
Unsupport the await!(..) macro.
2019-07-30 10:55:45 +02:00
Mazdak Farrokhzad
75e23ff411
Rollup merge of #62550 - Centril:rest-patterns, r=petrochenkov
...
Implement RFC 2707 + Parser recovery for range patterns
Implement https://github.com/rust-lang/rfcs/pull/2707 .
- Add a new basic syntactic pattern form `ast::PatKind::Rest` (parsed as `..` or `DOTDOT`) and simplify `ast::PatKind::{Slice, Tuple, TupleStruct}` as a result.
- Lower `ast::PatKind::Rest` in combination with the aforementioned `PatKind` variants as well as `PatKind::Ident`. The HIR remains unchanged for now (may be advisable to make slight adjustments later).
- Refactor `parser.rs` wrt. parsing sequences and lists of things in the process.
- Add parser recovery for range patterns of form `X..`, `X..=`, `X...`, `..Y`, `..=Y`, and `...Y`.
This should make it easy to actually support these patterns semantically later if we so desire.
cc https://github.com/rust-lang/rust/issues/62254
r? @petrochenkov
2019-07-28 11:11:04 +02:00
Mazdak Farrokhzad
b02941f2a6
Adjust pretty printing accordingly.
2019-07-28 06:53:38 +02:00
Mazdak Farrokhzad
f7c75cc11a
Add 'ast::PatKind::Rest'.
2019-07-28 06:53:38 +02:00
Vadim Petrochenkov
4d535bdf59
Move standard library injection into libsyntax_ext
2019-07-27 13:56:54 +03:00
Vadim Petrochenkov
0cdd18d0a7
pprust: Support macro macros
2019-07-15 12:42:07 +03:00
Vadim Petrochenkov
a2a1cd1864
pprust: Fix formatting regressions from the previous commits
...
Fix some remaining cases of bad formatting
Update some failing tests
2019-07-15 12:42:07 +03:00
Vadim Petrochenkov
75896011dc
pprust: Do not convert attributes into MetaItems for printing
...
Fixes https://github.com/rust-lang/rust/issues/62628
2019-07-15 12:42:07 +03:00
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
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
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
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