diff options
| author | bors <bors@rust-lang.org> | 2019-01-24 21:23:11 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2019-01-24 21:23:11 +0000 |
| commit | 278067d34d1535a840cf9c99bcb8b538bf5b109a (patch) | |
| tree | 7d3bd558b1a01bef4485dba03117107a7e132635 /src/libsyntax/parse | |
| parent | 01f8e25b15f4ab157c8e7c9c56054df7595ec0e1 (diff) | |
| parent | 5fa1016f93d77e43c3ed69b1155308616095cfcb (diff) | |
| download | rust-278067d34d1535a840cf9c99bcb8b538bf5b109a.tar.gz rust-278067d34d1535a840cf9c99bcb8b538bf5b109a.zip | |
Auto merge of #57879 - Centril:rollup, r=Centril
Rollup of 9 pull requests Successful merges: - #57380 (Fix Instant/Duration math precision & associativity on Windows) - #57606 (Get rid of the fake stack frame for reading from constants) - #57803 (Several changes to libunwind for SGX target) - #57846 (rustdoc: fix ICE from loading proc-macro stubs) - #57860 (Add os::fortanix_sgx::ffi module) - #57861 (Don't export table by default in wasm) - #57863 (Add suggestion for incorrect field syntax.) - #57867 (Fix std::future::from_generator documentation) - #57873 (Stabilize no_panic_pow) Failed merges: r? @ghost
Diffstat (limited to 'src/libsyntax/parse')
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index e4950d1b5a1..fb832afb748 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -2319,8 +2319,24 @@ impl<'a> Parser<'a> { let lo = self.span; // Check if a colon exists one ahead. This means we're parsing a fieldname. - let (fieldname, expr, is_shorthand) = if self.look_ahead(1, |t| t == &token::Colon) { + let (fieldname, expr, is_shorthand) = if self.look_ahead(1, |t| { + t == &token::Colon || t == &token::Eq + }) { let fieldname = self.parse_field_name()?; + + // Check for an equals token. This means the source incorrectly attempts to + // initialize a field with an eq rather than a colon. + if self.token == token::Eq { + self.diagnostic() + .struct_span_err(self.span, "expected `:`, found `=`") + .span_suggestion_with_applicability( + fieldname.span.shrink_to_hi().to(self.span), + "replace equals symbol with a colon", + ":".to_string(), + Applicability::MachineApplicable, + ) + .emit(); + } self.bump(); // `:` (fieldname, self.parse_expr()?, false) } else { |
