diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-01-18 10:34:18 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-01-18 10:34:18 +0100 |
| commit | 1f93d2b411cc6096ec460d4122252076fbda32b0 (patch) | |
| tree | 9b0e5bad93323132daab7ab0b73d8b62948c132b /compiler/rustc_ast/src | |
| parent | c3e237c3acb3f344d135b9ad20a1849ab0d34134 (diff) | |
| parent | 7889e99b553840de211482e4c86b2a145a968432 (diff) | |
| download | rust-1f93d2b411cc6096ec460d4122252076fbda32b0.tar.gz rust-1f93d2b411cc6096ec460d4122252076fbda32b0.zip | |
Rollup merge of #119967 - ShE3py:patkind-err, r=WaffleLapkin
Add `PatKind::Err` to AST/HIR #116715 added `thir::PatKind::Error`; this PR adds `hir::PatKind::Err` and `ast::PatKind::Err` (see https://github.com/rust-lang/rust/pull/118625#discussion_r1446587901.) --- ``@rustbot`` label +A-patterns r? WaffleLapkin
Diffstat (limited to 'compiler/rustc_ast/src')
| -rw-r--r-- | compiler/rustc_ast/src/ast.rs | 6 | ||||
| -rw-r--r-- | compiler/rustc_ast/src/mut_visit.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_ast/src/visit.rs | 2 |
3 files changed, 7 insertions, 3 deletions
diff --git a/compiler/rustc_ast/src/ast.rs b/compiler/rustc_ast/src/ast.rs index 21077c312bd..d0d98eb3d62 100644 --- a/compiler/rustc_ast/src/ast.rs +++ b/compiler/rustc_ast/src/ast.rs @@ -625,7 +625,8 @@ impl Pat { | PatKind::Range(..) | PatKind::Ident(..) | PatKind::Path(..) - | PatKind::MacCall(_) => {} + | PatKind::MacCall(_) + | PatKind::Err(_) => {} } } @@ -809,6 +810,9 @@ pub enum PatKind { /// A macro pattern; pre-expansion. MacCall(P<MacCall>), + + /// Placeholder for a pattern that wasn't syntactically well formed in some way. + Err(ErrorGuaranteed), } /// Whether the `..` is present in a struct fields pattern. diff --git a/compiler/rustc_ast/src/mut_visit.rs b/compiler/rustc_ast/src/mut_visit.rs index 450555d0cb5..90677151d25 100644 --- a/compiler/rustc_ast/src/mut_visit.rs +++ b/compiler/rustc_ast/src/mut_visit.rs @@ -1267,7 +1267,7 @@ pub fn noop_visit_pat<T: MutVisitor>(pat: &mut P<Pat>, vis: &mut T) { let Pat { id, kind, span, tokens } = pat.deref_mut(); vis.visit_id(id); match kind { - PatKind::Wild | PatKind::Rest | PatKind::Never => {} + PatKind::Wild | PatKind::Rest | PatKind::Never | PatKind::Err(_) => {} PatKind::Ident(_binding_mode, ident, sub) => { vis.visit_ident(ident); visit_opt(sub, |sub| vis.visit_pat(sub)); diff --git a/compiler/rustc_ast/src/visit.rs b/compiler/rustc_ast/src/visit.rs index 3617df931e2..89f50d3a0a7 100644 --- a/compiler/rustc_ast/src/visit.rs +++ b/compiler/rustc_ast/src/visit.rs @@ -568,7 +568,7 @@ pub fn walk_pat<'a, V: Visitor<'a>>(visitor: &mut V, pattern: &'a Pat) { walk_list!(visitor, visit_expr, lower_bound); walk_list!(visitor, visit_expr, upper_bound); } - PatKind::Wild | PatKind::Rest | PatKind::Never => {} + PatKind::Wild | PatKind::Rest | PatKind::Never | PatKind::Err(_) => {} PatKind::Tuple(elems) | PatKind::Slice(elems) | PatKind::Or(elems) => { walk_list!(visitor, visit_pat, elems); } |
