about summary refs log tree commit diff
path: root/tests/coverage/branch/lazy-boolean.rs
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2024-12-02 17:36:06 +0100
committerGitHub <noreply@github.com>2024-12-02 17:36:06 +0100
commit8f5a801b5cef26bce5e9a6f59f1ed354f601c595 (patch)
tree1aa34aed7347d929566c31ed940968181e5da762 /tests/coverage/branch/lazy-boolean.rs
parent15fda1e90bae7169e401aa5c5865a26511ac69c0 (diff)
parent267dcb28c289209462aa9695fa06e77ba532a4b1 (diff)
downloadrust-8f5a801b5cef26bce5e9a6f59f1ed354f601c595.tar.gz
rust-8f5a801b5cef26bce5e9a6f59f1ed354f601c595.zip
Rollup merge of #133730 - dtolnay:parentest, r=compiler-errors
Add pretty-printer parenthesis insertion test

This test demonstrates numerous bugs in rustc_ast_pretty, including all five of:

- Failing to insert parentheses where necessary to preserve the meaning of a syntax tree, producing invalid syntax.
- Failing to insert parentheses, producing valid syntax with the wrong meaning.
- Inserting too many parentheses.
- Inserting parentheses in the wrong place, producing invalid syntax.
- Losing syntactically significant parts of the syntax tree.

These pretty-printer bugs have consequences for `-Zunpretty=expanded`. The `cargo expand` subcommand cannot work reliably unless rustc can consistently produce valid Rust output. Erroneous syntax cannot be passed through rustfmt, or queried with [syn-select](https://crates.io/crates/syn-select).

The test in this PR is a port of a test from Syn that tests the automatic parenthesis insertion performed by Syn's `ToTokens` impls. In Syn we actually run this test over every expression in every Rust source file in the whole rust-lang/rust repo, including rustc and the standard library and tools and test suites. For the test here, I have only used a small selection of interesting expressions. This will serve as an easy spot to accumulate regression tests as the various bugs get fixed. Once rustc's pretty-printer is in better shape, it's possible that the test can be expanded to cover a larger set of expressions collected automatically like in Syn.
Diffstat (limited to 'tests/coverage/branch/lazy-boolean.rs')
0 files changed, 0 insertions, 0 deletions