rust/src/libsyntax
Pietro Albini 7523cdf101
Rollup merge of #54777 - zackmdavis:async_pretty_ice, r=cramertj
abolish ICE when pretty-printing async block

@jnetterf 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 to answer 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](https://hacktoberfest.digitalocean.com/stats/zackmdavis)??

Humbly resolves #54752.

r? @cramertj
2018-10-04 12:20:12 +02:00
..
attr Update error id to an unused one 2018-10-03 10:07:05 +02:00
diagnostics Remove OneVector 2018-09-26 10:43:37 +02:00
ext Auto merge of #52319 - tinco:issue_12590, r=pnkfelix 2018-09-27 09:51:12 +00:00
parse Auto merge of #52319 - tinco:issue_12590, r=pnkfelix 2018-09-27 09:51:12 +00:00
print abolish ICE when pretty-printing async block 2018-10-02 23:02:51 -07:00
util Remove OneVector 2018-09-26 10:43:37 +02:00
ast.rs Auto merge of #52319 - tinco:issue_12590, r=pnkfelix 2018-09-27 09:51:12 +00:00
build.rs rustc: Add some build scripts for librustc crates 2017-07-22 22:04:13 -07:00
Cargo.toml Use optimized SmallVec implementation 2018-08-23 10:45:53 +03:00
config.rs Auto merge of #54581 - petrochenkov:cfgattr, r=alexcrichton 2018-09-27 07:16:27 +00:00
diagnostic_list.rs Update error id to an unused one 2018-10-03 10:07:05 +02:00
early_buffered_lints.rs make it a migration lint 2018-07-23 21:55:51 -05:00
entry.rs Cleanup InternedString. 2016-11-21 09:00:56 +00:00
feature_gate.rs Extra proc macro gates are now at #54727 2018-10-01 12:37:07 -07:00
fold.rs Auto merge of #52319 - tinco:issue_12590, r=pnkfelix 2018-09-27 09:51:12 +00:00
json.rs mv (mod) codemap source_map 2018-08-19 23:01:00 +02:00
lib.rs Bump to 1.31.0 and bootstrap from 1.30 beta 2018-09-27 20:52:53 -07:00
ptr.rs Temporarily prohibit proc macro attributes placed after derives 2018-09-16 19:51:41 +03:00
README.md Replace many of the last references to readmes 2018-03-16 12:43:22 -05:00
show_span.rs use field init shorthand EVERYWHERE 2017-08-15 15:29:17 -07:00
source_map.rs Auto merge of #53949 - estebank:unclosed-delim, r=nikomatsakis 2018-09-09 01:36:58 +00:00
std_inject.rs mv codemap source_map 2018-08-19 23:01:01 +02:00
str.rs Inline char_at() and record_width. 2018-05-13 17:16:02 +10:00
test.rs Auto merge of #52319 - tinco:issue_12590, r=pnkfelix 2018-09-27 09:51:12 +00:00
test_snippet.rs mv (mod) codemap source_map 2018-08-19 23:01:00 +02:00
tokenstream.rs Track distinct spans for open and close delimiter 2018-09-08 19:01:48 -07:00
visit.rs Auto merge of #53815 - F001:if-let-guard, r=petrochenkov 2018-09-01 20:31:29 +00:00

The syntax crate contains those things concerned purely with syntax that is, the AST ("abstract syntax tree"), parser, pretty-printer, lexer, macro expander, and utilities for traversing ASTs.

For more information about how these things work in rustc, see the rustc guide: