about summary refs log tree commit diff
path: root/src/libsyntax/print
AgeCommit message (Collapse)AuthorLines
2018-10-19Prefer unwrap_or_else to unwrap_or in case of function calls/allocationsljedrz-1/+1
2018-10-02abolish ICE when pretty-printing async blockZack M. Davis-0/+3
Joshua Netterfield reported an ICE when the unused-parentheses lint triggered around an async block (#54752). In order to compose an autofixable suggestion, the lint invokes the pretty-printer on the unnecessarily-parenthesized expression. (One wonders why the lint doesn't just use `SourceMap::span_to_snippet` instead, to preserve the formatting of the original source?—but for that, you'd have to ask the author of 5c9f806d.) But then the pretty-printer panics when trying to call `<pprust::State as PrintState>::end` when `State.boxes` is empty. Empirically, the problem would seem to be solved if we start some "boxes" beforehand in the `ast::ExprKind::Async` arm of the big match in `print_expr_outer_attr_style`, exactly like we do in the immediately-preceding match arm for `ast::ExprKind::Block`—it would seem pretty ("pretty") reasonable for the pretty-printing of async blocks to work a lot like the pretty-printing of ordinary non-async blocks, right?? Of course, it would be shamefully cargo-culty to commit code on the basis of this kind of mere reasoning-by-analogy (in contrast to understanding the design of the pretty-printer in such detail that the correctness of the patch is comprehended with all the lucid certainty of mathematical proof, rather than being merely surmised by intuition). But maybe we care more about fixing the bug with high probability today, than with certainty in some indefinite hypothetical future? Maybe the effort is worth a fifth of a shirt?? Humbly resolves #54752.
2018-09-10Correctly close indentation blocks when pretty printing non-inline moduleTinco Andringa-1/+2
2018-09-10pretty=expanded should expand mod declarationsTinco Andringa-3/+10
2018-09-10Track whether module declarations are inline (fixes #12590)Tinco Andringa-4/+10
2018-09-01Auto merge of #53815 - F001:if-let-guard, r=petrochenkovbors-4/+8
refactor match guard This is the first step to implement RFC 2294: if-let-guard. Tracking issue: https://github.com/rust-lang/rust/issues/51114 The second step should be introducing another variant `IfLet` in the Guard enum. I separated them into 2 PRs for the convenience of reviewers. r? @petrochenkov
2018-08-30introduce Guard enumF001-4/+8
2018-08-27Remove Node* prefix from AnnNodevarkor-23/+21
2018-08-23Auto merge of #52602 - scottmcm:tryblock-expr, r=nikomatsakisbors-2/+2
Implement try block expressions I noticed that `try` wasn't a keyword yet in Rust 2018, so... ~~Fix​es https://github.com/rust-lang/rust/issues/52604~~ That was fixed by PR https://github.com/rust-lang/rust/pull/53135 cc https://github.com/rust-lang/rust/issues/31436 https://github.com/rust-lang/rust/issues/50412
2018-08-19Parse try blocks with the try keyword instead of do catch placeholderScott McMurray-1/+1
2018-08-19Rename `Catch` variants to `TryBlock`Scott McMurray-1/+1
(Not `Try` since `QuestionMark` is using that.)
2018-08-19mv (mod) codemap source_mapDonato Sciarra-8/+8
2018-08-19mv CodeMap SourceMapDonato Sciarra-5/+5
2018-07-29Auto merge of #52767 - ljedrz:avoid_format, r=petrochenkovbors-1/+1
Prefer to_string() to format!() Simple benchmarks suggest in some cases it can be faster by even 37%: ``` test converting_f64_long ... bench: 339 ns/iter (+/- 199) test converting_f64_short ... bench: 136 ns/iter (+/- 34) test converting_i32_long ... bench: 87 ns/iter (+/- 16) test converting_i32_short ... bench: 87 ns/iter (+/- 49) test converting_str ... bench: 54 ns/iter (+/- 15) test formatting_f64_long ... bench: 349 ns/iter (+/- 176) test formatting_f64_short ... bench: 145 ns/iter (+/- 14) test formatting_i32_long ... bench: 98 ns/iter (+/- 14) test formatting_i32_short ... bench: 93 ns/iter (+/- 15) test formatting_str ... bench: 86 ns/iter (+/- 23) ```
2018-07-29Auto merge of #52764 - sinkuu:cleanup, r=nikomatsakisbors-6/+4
Misc cleanups
2018-07-27Use slices where a vector is not necessaryljedrz-1/+1
2018-07-27Use str::repeatShotaro Yamada-6/+4
2018-07-27Prefer to_string() to format!()ljedrz-1/+1
2018-07-18Implement existential typesOliver Schneider-5/+19
2018-07-14Remove most of `PartialEq` impls from AST and HIR structuresVadim Petrochenkov-1/+3
2018-07-10Deny bare trait objects in in src/libsyntaxljedrz-12/+12
2018-06-27Generate the `NodeId` for `existential type` in the ASTOliver Schneider-1/+1
2018-06-26inclusive range syntax lint (`...` → `..=`)Zack M. Davis-2/+2
Our implementation ends up changing the `PatKind::Range` variant in the AST to take a `Spanned<RangeEnd>` instead of just a `RangeEnd`, because the alternative would be to try to infer the span of the range operator from the spans of the start and end subexpressions, which is both hideous and nontrivial to get right (whereas getting the change to the AST right was a simple game of type tennis). This is concerning #51043.
2018-06-23hygiene: Rename `MarkKind` to `Transparency`Vadim Petrochenkov-2/+2
Move `is_builtin` for `Mark` to a separate flag
2018-06-22Update libsyntax testTaylor Cramer-4/+14
2018-06-21async await desugaring and testsTaylor Cramer-6/+18
2018-06-21Parse async fn header.Without Boats-27/+20
This is gated on edition 2018 & the `async_await` feature gate. The parser will accept `async fn` and `async unsafe fn` as fn items. Along the same lines as `const fn`, only `async unsafe fn` is permitted, not `unsafe async fn`.The parser will not accept `async` functions as trait methods. To do a little code clean up, four fields of the function type struct have been merged into the new `FnHeader` struct: constness, asyncness, unsafety, and ABI. Also, a small bug in HIR printing is fixed: it previously printed `const unsafe fn` as `unsafe const fn`, which is grammatically incorrect.
2018-06-20Make GenericBound explicitvarkor-5/+5
2018-06-20Rename ParamBound(s) to GenericBound(s)varkor-5/+5
2018-06-20Rename TraitTyParamBound to ParamBound::Traitvarkor-4/+4
2018-06-20Remove name from GenericParamKind::Lifetimevarkor-22/+15
2018-06-20Use ParamBounds in WhereRegionPredicatevarkor-17/+15
2018-06-20Lift bounds into GenericParamvarkor-9/+14
2018-06-20Rename structures in astvarkor-10/+10
2018-06-20Remove methods from ast::GenericParam and ast::Genericsvarkor-1/+1
2018-06-20Refactor ast::GenericParam as a structvarkor-19/+17
2018-06-20Rename ast::GenericParam and ast::GenericArgvarkor-10/+10
It's so confusing to have everything having the same name, at least while refactoring.
2018-06-20Make method and variable names more consistentvarkor-6/+8
2018-06-20Rename "parameter" to "arg"varkor-14/+14
2018-06-20Rename PathParameter(s) to GenericArg(s)varkor-7/+7
2018-06-20Rename *Parameter to *Paramvarkor-4/+4
2018-06-20Consolidate PathParameters and AngleBracketedParameterDatavarkor-19/+10
2018-06-14create multiple HIR items for a use statementQuietMisdreavus-1/+1
2018-05-26Auto merge of #51072 - petrochenkov:ifield, r=eddybbors-2/+2
Use `Ident`s for fields in HIR Continuation of https://github.com/rust-lang/rust/pull/49718, part of https://github.com/rust-lang/rust/issues/49300
2018-05-26Add `Ident::as_str` helperVadim Petrochenkov-2/+2
2018-05-24restore emplacement syntax (obsolete)Niko Matsakis-0/+7
2018-05-22rustc: Correctly pretty-print macro delimitersAlex Crichton-54/+50
This commit updates the `Mac_` AST structure to keep track of the delimiters that it originally had for its invocation. This allows us to faithfully pretty-print macro invocations not using parentheses (e.g. `vec![...]`). This in turn helps procedural macros due to #43081. Closes #50840
2018-05-19rustc: introduce {ast,hir}::AnonConst to consolidate so-called "embedded ↵Eduard-Mihai Burtescu-6/+6
constants".
2018-05-17Turn some functions from `token.rs` into methods on `Ident`Vadim Petrochenkov-1/+1
2018-05-16Auto merge of #50045 - est31:label_break_value, r=eddybbors-3/+12
Implement label break value (RFC 2046) Implement label-break-value (#48594).