summary refs log tree commit diff
path: root/compiler/rustc_ast_pretty/src/pprust
AgeCommit message (Collapse)AuthorLines
2020-11-12Rollup merge of #78836 - fanzier:struct-and-slice-destructuring, r=petrochenkovMara Bos-11/+10
Implement destructuring assignment for structs and slices This is the second step towards implementing destructuring assignment (RFC: rust-lang/rfcs#2909, tracking issue: #71126). This PR is the second part of #71156, which was split up to allow for easier review. Note that the first PR (#78748) is not merged yet, so it is included as the first commit in this one. I thought this would allow the review to start earlier because I have some time this weekend to respond to reviews. If ``@petrochenkov`` prefers to wait until the first PR is merged, I totally understand, of course. This PR implements destructuring assignment for (tuple) structs and slices. In order to do this, the following *parser change* was necessary: struct expressions are not required to have a base expression, i.e. `Struct { a: 1, .. }` becomes legal (in order to act like a struct pattern). Unfortunately, this PR slightly regresses the diagnostics implemented in #77283. However, it is only a missing help message in `src/test/ui/issues/issue-77218.rs`. Other instances of this diagnostic are not affected. Since I don't exactly understand how this help message works and how to fix it yet, I was hoping it's OK to regress this temporarily and fix it in a follow-up PR. Thanks to ``@varkor`` who helped with the implementation, particularly around the struct rest changes. r? ``@petrochenkov``
2020-11-11Implement destructuring assignment for structs and slicesFabian Zaiser-11/+10
Co-authored-by: varkor <github@varkor.com>
2020-11-09Do not collect tokens for doc commentsVadim Petrochenkov-1/+1
2020-10-30Fix even more clippy warningsJoshua Nelson-7/+5
2020-10-30Rollup merge of #77888 - LingMan:ast_pretty_tt_prepend_space, r=jyn514Yuki Okushi-18/+7
Simplify a nested bool match Logically this first eliminates the innermost match by merging the patterns. Then, in a second step, turns the newly innermost match into a `matches!` call.
2020-10-20Drop unneeded `mut`LingMan-1/+1
These parameters don't get modified.
2020-10-16Parse inline const expressionsSantiago Pastorino-0/+11
2020-10-14Simplify a nested bool matchLingMan-18/+7
Logically this first eliminates the innermost match by merging the patterns. Then, in a second step, turns the newly innermost match into a `matches!` call.
2020-10-11Allow skipping extra paren insertion during AST pretty-printingAaron Hill-5/+26
Fixes #74616 Makes progress towards #43081 Unblocks PR #76130 When pretty-printing an AST node, we may insert additional parenthesis to ensure that precedence is properly preserved in code we output. However, the proc macro implementation relies on comparing a pretty-printed AST node to the captured `TokenStream`. Inserting extra parenthesis changes the structure of the reparsed `TokenStream`, making the comparison fail. This PR refactors the AST pretty-printing code to allow skipping the insertion of additional parenthesis. Several freestanding methods are moved to trait methods on `PrintState`, which keep track of an internal `insert_extra_parens` flag. This flag is normally `true`, but we expose a public method which allows pretty-printing a nonterminal with `insert_extra_parens = false`. To avoid changing the public interface of `rustc_ast_pretty`, the freestanding `_to_string` methods are changed to delegate to a newly-crated `State`. The main pretty-printing code is moved to a new `state` module to ensure that it does not accidentally call any of these public helper functions (instead, the internal functions with the same name should be used).
2020-10-11Move pprust code to a 'state' submoduleAaron Hill-0/+2984
2020-09-10Fully integrate token collection for additional AST structsAaron Hill-2/+5
This commit contains miscellaneous changes that don't fit into any of the other commits in this PR
2020-08-30mv compiler to compiler/mark-0/+60