diff options
| author | Stuart Cook <Zalathar@users.noreply.github.com> | 2025-04-07 22:29:17 +1000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-04-07 22:29:17 +1000 |
| commit | 82df6229b6383ba1395eb0599309b30e257c3c3b (patch) | |
| tree | 8331b59a1afd22ffb5f782b3ff81ba654b987253 /compiler/rustc_ast_pretty | |
| parent | 8fb32ab8e563124fe0968a2878b7f5b5d0e8d722 (diff) | |
| parent | 909f4492475988ba5e1b84efadacb16eb7d7ff0e (diff) | |
| download | rust-82df6229b6383ba1395eb0599309b30e257c3c3b.tar.gz rust-82df6229b6383ba1395eb0599309b30e257c3c3b.zip | |
Rollup merge of #139035 - nnethercote:PatKind-Missing, r=oli-obk
Add new `PatKind::Missing` variants To avoid some ugly uses of `kw::Empty` when handling "missing" patterns, e.g. in bare fn tys. Helps with #137978. Details in the individual commits. r? ``@oli-obk``
Diffstat (limited to 'compiler/rustc_ast_pretty')
| -rw-r--r-- | compiler/rustc_ast_pretty/src/pprust/state.rs | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/compiler/rustc_ast_pretty/src/pprust/state.rs b/compiler/rustc_ast_pretty/src/pprust/state.rs index 3dbfc191f8f..683ad5c66bf 100644 --- a/compiler/rustc_ast_pretty/src/pprust/state.rs +++ b/compiler/rustc_ast_pretty/src/pprust/state.rs @@ -1622,9 +1622,9 @@ impl<'a> State<'a> { fn print_pat(&mut self, pat: &ast::Pat) { self.maybe_print_comment(pat.span.lo()); self.ann.pre(self, AnnNode::Pat(pat)); - /* Pat isn't normalized, but the beauty of it - is that it doesn't matter */ + /* Pat isn't normalized, but the beauty of it is that it doesn't matter */ match &pat.kind { + PatKind::Missing => unreachable!(), PatKind::Wild => self.word("_"), PatKind::Never => self.word("!"), PatKind::Ident(BindingMode(by_ref, mutbl), ident, sub) => { @@ -1946,12 +1946,7 @@ impl<'a> State<'a> { if let Some(eself) = input.to_self() { self.print_explicit_self(&eself); } else { - let invalid = if let PatKind::Ident(_, ident, _) = input.pat.kind { - ident.name == kw::Empty - } else { - false - }; - if !invalid { + if !matches!(input.pat.kind, PatKind::Missing) { self.print_pat(&input.pat); self.word(":"); self.space(); |
