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 Update pretty test for derive attributes 2017-02-05 12:22:29 +10:30
asm-clobbers.rs Strip all leading/trailing newlines 2015-03-15 09:08:21 -07:00
asm-options.rs pprust: Fix asm options 2014-12-22 13:37:10 +09:00
attr-derive.rs Update pretty test for derive attributes 2017-02-05 12:22:29 +10:30
attr-fn-inner.rs Test fixes and rebase conflicts 2015-02-17 19:42:28 -08:00
attr-literals.rs Stabilize 'attr_literals' feature. 2018-08-23 19:06:07 -07:00
auto-trait.rs Fix unsafe auto trait pretty print. 2017-11-03 16:13:23 -02:00
blank-lines.rs Fix #27567: remove --crate-type=lib from pretty test 2015-08-11 13:00:38 +02:00
block-comment-multiple-asterisks.rs Fix #27567: remove --crate-type=lib from pretty test 2015-08-11 13:00:38 +02:00
block-comment-trailing-whitespace.rs Fix #27567: remove --crate-type=lib from pretty test 2015-08-11 13:00:38 +02:00
block-comment-trailing-whitespace2.rs Fix #27567: remove --crate-type=lib from pretty test 2015-08-11 13:00:38 +02:00
block-comment-wchar.pp Model lexer: Fix remaining issues 2015-04-21 12:02:12 +02:00
block-comment-wchar.rs Model lexer: Fix remaining issues 2015-04-21 12:02:12 +02:00
block-disambig.rs Changed most vec! invocations to use square braces 2016-10-31 22:51:40 +00:00
cast-lt.pp syntax: gensym the injected std/core extern crates in the Rust 2018 edition. 2018-08-14 07:06:46 +03:00
cast-lt.rs fix expected output of pretty/cast-lt and issue-4264 tests 2018-07-12 01:19:27 +02:00
closure-reform-pretty.rs Fix whitespacing issues in pretty-printing of bounds 2017-12-20 00:23:18 +03:00
disamb-stmt-expr.rs Mass rename uint/int to usize/isize 2015-03-26 12:10:22 -07:00
do1.rs Use assert_eq! instead of assert! in tests 2015-06-13 14:55:55 +03:00
doc-comments.rs Fix #27567: remove --crate-type=lib from pretty test 2015-08-11 13:00:38 +02:00
empty-impl.rs Fix #27567: remove --crate-type=lib from pretty test 2015-08-11 13:00:38 +02:00
empty-lines.rs Fix #27567: remove --crate-type=lib from pretty test 2015-08-11 13:00:38 +02:00
example1.rs Reliciense makefiles and testsuite. Yup. 2012-12-10 17:32:58 -08:00
example2.pp tests: relicense .pp files. Oddly not caught during local testing. 2012-12-10 18:15:39 -08:00
example2.rs Reliciense makefiles and testsuite. Yup. 2012-12-10 17:32:58 -08:00
fn-return.rs Make output type in ast::FnDecl optional 2015-01-18 22:49:19 +09:00
fn-types.rs fix pretty tests 2015-01-05 17:22:17 -05:00
for-comment.rs Fix some pretty printing tests 2016-10-18 23:23:40 +03:00
import-renames.rs Fix #27567: remove --crate-type=lib from pretty test 2015-08-11 13:00:38 +02:00
issue-4264.pp syntax: gensym the injected std/core extern crates in the Rust 2018 edition. 2018-08-14 07:06:46 +03:00
issue-4264.rs Add an intital HIR and lowering step 2015-09-03 10:02:36 +12:00
issue-19077.rs Fixes to the roll-up 2014-11-23 15:23:39 -05:00
issue-25031.rs Correct pretty-printing of type Foo<T> where T: Bound = ...; 2015-05-04 10:21:39 +02:00
issue-30731.rs libsyntax: fix pretty printing of macro with braces 2016-01-28 09:19:43 +01:00
issue-31073.pp Fix pretty_printer to print omitted type _ marker 2016-01-25 21:36:06 +05:30
issue-31073.rs Fix pretty_printer to print omitted type _ marker 2016-01-25 21:36:06 +05:30
issue-54752-async-block.rs abolish ICE when pretty-printing async block 2018-10-02 23:02:51 -07:00
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
let.rs Add a pretty-print test 2015-01-02 22:28:53 +09:00
lifetime.rs Fix pretty-printing of lifetime bound 2016-06-29 23:40:29 +09:00
match-block-expr.rs Remove all i suffixes 2015-01-30 04:38:54 +01:00
match-naked-expr-medium.rs Remove all i suffixes 2015-01-30 04:38:54 +01:00
match-naked-expr.rs Remove all i suffixes 2015-01-30 04:38:54 +01:00
path-type-bounds.rs Fix whitespacing issues in pretty-printing of bounds 2017-12-20 00:23:18 +03:00
raw-str-nonexpr.rs rustc: Add support for extern crate foo as bar 2015-03-24 14:55:15 -07:00
stmt_expr_attributes.rs Remove all unstable placement features 2018-04-03 11:02:34 +02:00
struct-pattern.rs Preserve struct field pattern shorthand in the prettyprinter. 2014-10-27 00:35:35 -07:00
struct-tuple.rs Mass rename uint/int to usize/isize 2015-03-26 12:10:22 -07:00
tag-blank-lines.rs Add enum variants to the type namespace 2014-09-19 15:11:00 +12:00
top-level-doc-comments.rs syntax: Always pretty print a newline after doc comments 2016-03-07 10:25:02 -05:00
trait-polarity.rs fix pretty test fallout 2015-01-16 11:47:48 +01:00
trait-safety.rs Mass rename uint/int to usize/isize 2015-03-26 12:10:22 -07:00
unary-op-disambig.rs Fix #27567: remove --crate-type=lib from pretty test 2015-08-11 13:00:38 +02:00
vec-comments.pp Remove all i suffixes 2015-01-30 04:38:54 +01:00
vec-comments.rs Remove all i suffixes 2015-01-30 04:38:54 +01:00
where-clauses.rs Fix pretty-printing of lifetime bound 2016-06-29 23:40:29 +09:00