about summary refs log tree commit diff
path: root/compiler/rustc_parse/src/parser/diagnostics.rs
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2023-01-17 01:50:45 +0000
committerEsteban Küber <esteban@kuber.com.ar>2023-01-17 01:58:37 +0000
commitc847a01a3b1f620c4fdb98c75805033e768975d1 (patch)
tree85d60ad025831d5a45300a39d385614e1b645ddf /compiler/rustc_parse/src/parser/diagnostics.rs
parent2d824206655bfb26cb5eed43490ee396542b153e (diff)
downloadrust-c847a01a3b1f620c4fdb98c75805033e768975d1.tar.gz
rust-c847a01a3b1f620c4fdb98c75805033e768975d1.zip
Emit fewer errors on patterns with possible type ascription
Diffstat (limited to 'compiler/rustc_parse/src/parser/diagnostics.rs')
-rw-r--r--compiler/rustc_parse/src/parser/diagnostics.rs2
1 files changed, 2 insertions, 0 deletions
diff --git a/compiler/rustc_parse/src/parser/diagnostics.rs b/compiler/rustc_parse/src/parser/diagnostics.rs
index 07bd76dc39b..eda7046c748 100644
--- a/compiler/rustc_parse/src/parser/diagnostics.rs
+++ b/compiler/rustc_parse/src/parser/diagnostics.rs
@@ -2500,6 +2500,8 @@ impl<'a> Parser<'a> {
                     Ok(ty) => {
                         err.span_label(ty.span, "specifying the type of a pattern isn't supported");
                         self.restore_snapshot(snapshot_type);
+                        let new_span = first_pat.span.to(ty.span);
+                        first_pat = self.mk_pat(new_span, PatKind::Wild);
                     }
                 }
                 err.emit();