rust/src/test/pretty
Zack M. Davis 1081bbbfc5 abolish ICE when pretty-printing async block
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-10-02 23:02:51 -07:00
..
auxiliary
asm-clobbers.rs
asm-options.rs
attr-derive.rs
attr-fn-inner.rs
attr-literals.rs Stabilize 'attr_literals' feature. 2018-08-23 19:06:07 -07:00
auto-trait.rs
blank-lines.rs
block-comment-multiple-asterisks.rs
block-comment-trailing-whitespace2.rs
block-comment-trailing-whitespace.rs
block-comment-wchar.pp
block-comment-wchar.rs
block-disambig.rs
cast-lt.pp
cast-lt.rs
closure-reform-pretty.rs
disamb-stmt-expr.rs
do1.rs
doc-comments.rs
empty-impl.rs
empty-lines.rs
example1.rs
example2.pp
example2.rs
fn-return.rs
fn-types.rs
for-comment.rs
import-renames.rs
issue_12590_a.rs Track whether module declarations are inline (fixes #12590) 2018-09-10 12:33:37 +02:00
issue_12590_b.rs Track whether module declarations are inline (fixes #12590) 2018-09-10 12:33:37 +02:00
issue_12590_c.pp update result of issue 12590 test 2018-09-10 15:44:42 +02:00
issue_12590_c.rs Correctly close indentation blocks when pretty printing non-inline module 2018-09-10 12:33:38 +02:00
issue-4264.pp
issue-4264.rs
issue-19077.rs
issue-25031.rs
issue-30731.rs
issue-31073.pp
issue-31073.rs
issue-54752-async-block.rs abolish ICE when pretty-printing async block 2018-10-02 23:02:51 -07:00
let.rs
lifetime.rs
match-block-expr.rs
match-naked-expr-medium.rs
match-naked-expr.rs
path-type-bounds.rs
raw-str-nonexpr.rs
stmt_expr_attributes.rs
struct-pattern.rs
struct-tuple.rs
tag-blank-lines.rs
top-level-doc-comments.rs
trait-polarity.rs
trait-safety.rs
unary-op-disambig.rs
vec-comments.pp
vec-comments.rs
where-clauses.rs