rust/tests/ui/unpretty
Nicholas Nethercote 9f089e080c Add {ast,hir,thir}::PatKind::Missing variants.
"Missing" patterns are possible in bare fn types (`fn f(u32)`) and
similar places. Currently these are represented in the AST with
`ast::PatKind::Ident` with no `by_ref`, no `mut`, an empty ident, and no
sub-pattern. This flows through to `{hir,thir}::PatKind::Binding` for
HIR and THIR.

This is a bit nasty. It's very non-obvious, and easy to forget to check
for the exceptional empty identifier case.

This commit adds a new variant, `PatKind::Missing`, to do it properly.

The process I followed:
- Add a `Missing` variant to `{ast,hir,thir}::PatKind`.
- Chang `parse_param_general` to produce `ast::PatKind::Missing`
  instead of `ast::PatKind::Missing`.
- Look through `kw::Empty` occurrences to find functions where an
  existing empty ident check needs replacing with a `PatKind::Missing`
  check: `print_param`, `check_trait_item`, `is_named_param`.
- Add a `PatKind::Missing => unreachable!(),` arm to every exhaustive
  match identified by the compiler.
- Find which arms are actually reachable by running the test suite,
  changing them to something appropriate, usually by looking at what
  would happen to a `PatKind::Ident`/`PatKind::Binding` with no ref, no
  `mut`, an empty ident, and no subpattern.

Quite a few of the `unreachable!()` arms were never reached. This makes
sense because `PatKind::Missing` can't happen in every pattern, only
in places like bare fn tys and trait fn decls.

I also tried an alternative approach: modifying `ast::Param::pat` to
hold an `Option<P<Pat>>` instead of a `P<Pat>`, but that quickly turned
into a very large and painful change. Adding `PatKind::Missing` is much
easier.
2025-03-28 09:18:57 +11:00
..
auxiliary
ast-const-trait-bound.rs
ast-const-trait-bound.stdout
avoid-crash.rs compiletest: Support matching on diagnostics without a span 2025-03-25 17:33:09 +03:00
avoid-crash.stderr
bad-literal.rs
bad-literal.stderr
bad-literal.stdout
box.rs turn rustc_box into an intrinsic 2025-01-03 12:01:31 +01:00
box.stdout turn rustc_box into an intrinsic 2025-01-03 12:01:31 +01:00
debug-fmt-hir.rs Pre-commit unpretty HIR test 2025-02-18 21:34:35 +01:00
debug-fmt-hir.stdout Render implicit self with their shorthand syntax in HIR pretty printing 2025-02-22 17:12:19 +01:00
deprecated-attr.rs Fix pretty printing of parsed attrs in hir_pretty 2025-03-10 02:04:26 +00:00
deprecated-attr.stdout Fix pretty printing of parsed attrs in hir_pretty 2025-03-10 02:04:26 +00:00
diagnostic-attr.rs Pretty-print #[deprecated] attribute in HIR. 2025-03-05 01:51:07 +00:00
diagnostic-attr.stdout Pretty-print #[deprecated] attribute in HIR. 2025-03-05 01:51:07 +00:00
expanded-exhaustive.rs Add {ast,hir,thir}::PatKind::Missing variants. 2025-03-28 09:18:57 +11:00
expanded-exhaustive.stdout Add {ast,hir,thir}::PatKind::Missing variants. 2025-03-28 09:18:57 +11:00
expanded-interpolation.rs Add test of parenthesizing break value by AST pretty-printer 2024-06-23 17:17:30 -07:00
expanded-interpolation.stdout Parenthesize break values containing leading label 2024-07-01 17:19:58 -07:00
extern-static.rs Print safety correctly in extern static items 2024-10-24 00:41:27 +00:00
extern-static.stdout Print safety correctly in extern static items 2024-10-24 00:41:27 +00:00
flattened-format-args.rs
flattened-format-args.stdout
hir-tree.rs
let-else-hir.rs
let-else-hir.stdout
mir-unpretty.rs
mir-unpretty.stderr
self-hir.rs Render implicit self with their shorthand syntax in HIR pretty printing 2025-02-22 17:12:19 +01:00
self-hir.stdout Render implicit self with their shorthand syntax in HIR pretty printing 2025-02-22 17:12:19 +01:00
staged-api-invalid-path-108697.rs Fix test that relies on error language 2025-02-16 09:08:24 +00:00
staged-api-invalid-path-108697.stderr Fix test that relies on error language 2025-02-16 09:08:24 +00:00
unpretty-expr-fn-arg.rs
unpretty-expr-fn-arg.stdout Exhaustively handle expressions in patterns 2025-01-08 07:33:46 +00:00
unsafe-attr.rs Add AST unpretty test for unsafe attribute 2024-10-26 13:31:24 +02:00
unsafe-attr.stdout Print unsafety of attribute in AST unpretty 2024-10-26 13:33:36 +02:00