about summary refs log tree commit diff
path: root/compiler/rustc_parse/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-10-11 00:36:26 +0000
committerbors <bors@rust-lang.org>2022-10-11 00:36:26 +0000
commit518263d889818d16a09a8260f212f8ff4bf345f1 (patch)
tree2c9eac4a16c0017d787803260d69c9ca8e476f47 /compiler/rustc_parse/src
parent36c8e291a617ae6bd4b8ff13c54c82862eaf0eec (diff)
parenta52eba4a89df69abb1a104bd472f69c70fe20b8f (diff)
downloadrust-518263d889818d16a09a8260f212f8ff4bf345f1.tar.gz
rust-518263d889818d16a09a8260f212f8ff4bf345f1.zip
Auto merge of #102896 - matthiaskrgr:rollup-jg5xawz, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #101360 (Point out incompatible closure bounds)
 - #101789 (`let`'s not needed in struct field definitions)
 - #102846 (update to syn-1.0.102)
 - #102871 (rustdoc: clean up overly complex `.trait-impl` CSS selectors)
 - #102876 (suggest candidates for unresolved import)
 - #102888 (Improve rustdoc-gui search-color test)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_parse/src')
-rw-r--r--compiler/rustc_parse/src/parser/item.rs18
1 files changed, 17 insertions, 1 deletions
diff --git a/compiler/rustc_parse/src/parser/item.rs b/compiler/rustc_parse/src/parser/item.rs
index 25425fbb2c6..e82044a89c4 100644
--- a/compiler/rustc_parse/src/parser/item.rs
+++ b/compiler/rustc_parse/src/parser/item.rs
@@ -1788,7 +1788,23 @@ impl<'a> Parser<'a> {
                     }
                 }
             } else {
-                self.expected_ident_found()
+                let mut err = self.expected_ident_found();
+                if let Some((ident, _)) = self.token.ident() && ident.as_str() == "let" {
+                    self.bump(); // `let`
+                    let span = self.prev_token.span.until(self.token.span);
+                    err.span_suggestion(
+                        span,
+                        "remove the let, the `let` keyword is not allowed in struct field definitions",
+                        String::new(),
+                        Applicability::MachineApplicable,
+                    );
+                    err.note("the `let` keyword is not allowed in `struct` fields");
+                    err.note("see <https://doc.rust-lang.org/book/ch05-01-defining-structs.html> for more information");
+                    err.emit();
+                    self.bump();
+                    return Ok(ident);
+                }
+                err
             };
             return Err(err);
         }