diff options
| author | bors <bors@rust-lang.org> | 2022-09-08 15:53:14 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-09-08 15:53:14 +0000 |
| commit | 87788097b776f8e3662f76627944230684b671bd (patch) | |
| tree | d9dcf415e1876695a0a26f483a6dba10d66d4917 /compiler/rustc_parse/src/parser | |
| parent | 24d69920201563f0ee7b530f1cda0f171b205cc2 (diff) | |
| parent | 720a82dd52609f0dd90a51da4dd53fb51116241e (diff) | |
| download | rust-87788097b776f8e3662f76627944230684b671bd.tar.gz rust-87788097b776f8e3662f76627944230684b671bd.zip | |
Auto merge of #101577 - Dylan-DPC:rollup-l9xw7i7, r=Dylan-DPC
Rollup of 7 pull requests Successful merges: - #98933 (Opaque types' generic params do not imply anything about their hidden type's lifetimes) - #101041 (translations(rustc_session): migrates rustc_session to use SessionDiagnostic - Pt. 2) - #101424 (Adjust and slightly generalize operator error suggestion) - #101496 (Allow lower_lifetime_binder receive a closure) - #101501 (Allow lint passes to be bound by `TyCtxt`) - #101515 (Recover from typo where == is used in place of =) - #101545 (Remove unnecessary `PartialOrd` and `Ord`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_parse/src/parser')
| -rw-r--r-- | compiler/rustc_parse/src/parser/diagnostics.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/compiler/rustc_parse/src/parser/diagnostics.rs b/compiler/rustc_parse/src/parser/diagnostics.rs index ad49227222b..be524db785b 100644 --- a/compiler/rustc_parse/src/parser/diagnostics.rs +++ b/compiler/rustc_parse/src/parser/diagnostics.rs @@ -713,6 +713,14 @@ pub(crate) struct RemoveLet { pub span: Span, } +#[derive(SessionDiagnostic)] +#[diag(parser::use_eq_instead)] +pub(crate) struct UseEqInstead { + #[primary_span] + #[suggestion_short(applicability = "machine-applicable", code = "=")] + pub span: Span, +} + // SnapshotParser is used to create a snapshot of the parser // without causing duplicate errors being emitted when the `Parser` // is dropped. @@ -957,6 +965,14 @@ impl<'a> Parser<'a> { } } + if self.token.kind == TokenKind::EqEq + && self.prev_token.is_ident() + && expected.iter().any(|tok| matches!(tok, TokenType::Token(TokenKind::Eq))) + { + // Likely typo: `=` → `==` in let expr or enum item + return Err(self.sess.create_err(UseEqInstead { span: self.token.span })); + } + let expect = tokens_to_string(&expected); let actual = super::token_descr(&self.token); let (msg_exp, (label_sp, label_exp)) = if expected.len() > 1 { |
