about summary refs log tree commit diff
path: root/compiler/rustc_parse/src/errors.rs
diff options
context:
space:
mode:
authorJubilee <46493976+workingjubilee@users.noreply.github.com>2023-10-06 16:37:47 -0700
committerGitHub <noreply@github.com>2023-10-06 16:37:47 -0700
commit0d68e416a568ae0e206bcf65a2c5234565ba3bf5 (patch)
tree0383e5efae6e11439dcae32184ba5c06df37c69e /compiler/rustc_parse/src/errors.rs
parent6d1c3a40cb4ce7b455e44834f79c5ecf39cd5021 (diff)
parent8fd345dd4b85b6758896995beb5b0417efd52364 (diff)
downloadrust-0d68e416a568ae0e206bcf65a2c5234565ba3bf5.tar.gz
rust-0d68e416a568ae0e206bcf65a2c5234565ba3bf5.zip
Rollup merge of #116400 - estebank:issue-78585, r=WaffleLapkin
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]