Skip to content

Commit

Permalink
Rollup merge of rust-lang#125236 - dtolnay:expandtest, r=nnethercote
Browse files Browse the repository at this point in the history
Add tests for `-Zunpretty=expanded` ported from stringify's tests

This PR adds a new set of tests for the AST pretty-printer.

Previously, pretty-printer edge cases were tested by way of `stringify!` in [tests/ui/macros/stringify.rs](https://github.com/rust-lang/rust/blob/1.78.0/tests/ui/macros/stringify.rs), such as the tests added by rust-lang@419b269 and rust-lang@527e2ea.

Those tests will no longer provide effective coverage of the AST pretty-printer after rust-lang#124141. `Nonterminal` and `TokenKind::Interpolated` are being removed, and a consequence is that `stringify!` will perform token stream pretty printing, instead of AST pretty printing, in all of the `stringify!` cases including $:expr and all other interpolations.

This PR adds 2 new ui tests with `compile-flags: -Zunpretty=expanded`:

- **tests/ui/unpretty/expanded-exhaustive.rs** — this test aims for exhaustive coverage of all the variants of `ExprKind`, `ItemKind`, `PatKind`, `StmtKind`, `TyKind`, and `VisibilityKind`. Some parts could use being fleshed out further, but the current state is roughly on par with what exists in the old stringify-based tests.

- **tests/ui/unpretty/expanded-interpolation.rs** — this test covers tricky macro metavariable edge cases that require the AST pretty printer to synthesize parentheses in order for the printed code to be valid Rust syntax.

r? `@nnethercote`
  • Loading branch information
jieyouxu committed May 18, 2024
2 parents f08746a + 3e05be5 commit ffc04df
Show file tree
Hide file tree
Showing 10 changed files with 1,807 additions and 51 deletions.
1 change: 0 additions & 1 deletion src/tools/tidy/src/issues.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2915,7 +2915,6 @@ ui/macros/issue-95267.rs
ui/macros/issue-95533.rs
ui/macros/issue-98466-allow.rs
ui/macros/issue-98466.rs
ui/macros/issue-98790.rs
ui/macros/issue-99261.rs
ui/macros/issue-99265.rs
ui/macros/issue-99907.rs
Expand Down
1 change: 1 addition & 0 deletions src/tools/tidy/src/ui_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const EXTENSION_EXCEPTION_PATHS: &[&str] = &[
"tests/ui/macros/not-utf8.bin", // testing including data with the include macros
"tests/ui/macros/syntax-extension-source-utils-files/includeme.fragment", // more include
"tests/ui/proc-macro/auxiliary/included-file.txt", // more include
"tests/ui/unpretty/auxiliary/data.txt", // more include
"tests/ui/invalid/foo.natvis.xml", // sample debugger visualizer
"tests/ui/sanitizer/dataflow-abilist.txt", // dataflow sanitizer ABI list file
"tests/ui/shell-argfiles/shell-argfiles.args", // passing args via a file
Expand Down
24 changes: 0 additions & 24 deletions tests/ui/macros/issue-98790.rs

This file was deleted.

1 change: 1 addition & 0 deletions tests/ui/unpretty/auxiliary/data.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
data for include_bytes in ../expanded-exhaustive.rs
Loading

0 comments on commit ffc04df

Please sign in to comment.