about summary refs log tree commit diff
path: root/compiler/rustc_parse/src/errors.rs
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2023-10-03 21:21:02 +0000
committerEsteban Küber <esteban@kuber.com.ar>2023-10-03 21:21:02 +0000
commit745c1ea4388864d6a832aeacb9fc3b9db1ab9c2f (patch)
tree75c968f15f07493db47d6ca1cac463be4fe9bfe7 /compiler/rustc_parse/src/errors.rs
parenta6dfd89fa76e5dda36d07463d0e54268d6240b49 (diff)
downloadrust-745c1ea4388864d6a832aeacb9fc3b9db1ab9c2f.tar.gz
rust-745c1ea4388864d6a832aeacb9fc3b9db1ab9c2f.zip
Detect missing `=>` after match guard during parsing
```
error: expected one of `,`, `:`, or `}`, found `.`
  --> $DIR/missing-fat-arrow.rs:25:14
   |
LL |         Some(a) if a.value == b {
   |                               - while parsing this struct
LL |             a.value = 1;
   |             -^ expected one of `,`, `:`, or `}`
   |             |
   |             while parsing this struct field
   |
help: try naming a field
   |
LL |             a: a.value = 1;
   |             ++
help: you might have meant to start a match arm after the match guard
   |
LL |         Some(a) if a.value == b => {
   |                                 ++
```

Fix #78585.
Diffstat (limited to 'compiler/rustc_parse/src/errors.rs')
-rw-r--r--compiler/rustc_parse/src/errors.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/compiler/rustc_parse/src/errors.rs b/compiler/rustc_parse/src/errors.rs
index 7c75e440aaa..aeb4fd0a304 100644
--- a/compiler/rustc_parse/src/errors.rs
+++ b/compiler/rustc_parse/src/errors.rs
@@ -431,6 +431,17 @@ pub(crate) struct ExpectedElseBlock {
 }
 
 #[derive(Diagnostic)]
+#[diag(parse_expected_struct_field)]
+pub(crate) struct ExpectedStructField {
+    #[primary_span]
+    #[label]
+    pub span: Span,
+    pub token: Token,
+    #[label(parse_ident_label)]
+    pub ident_span: Span,
+}
+
+#[derive(Diagnostic)]
 #[diag(parse_outer_attribute_not_allowed_on_if_else)]
 pub(crate) struct OuterAttributeNotAllowedOnIfElse {
     #[primary_span]