about summary refs log tree commit diff
path: root/compiler/rustc_parse/src/parser
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-08-14 21:35:16 +0000
committerbors <bors@rust-lang.org>2022-08-14 21:35:16 +0000
commitb8c0a01b2b651416f5e7461209ff1a93a98619e4 (patch)
tree6e77649de55a0a57466b0827cb4963fb5d9ecfaf /compiler/rustc_parse/src/parser
parent801821d1560f84e4716fcbd9244ec959320a13d5 (diff)
parent59795d0cb275aef6c9bce021492e56f2a218b5b9 (diff)
downloadrust-b8c0a01b2b651416f5e7461209ff1a93a98619e4.tar.gz
rust-b8c0a01b2b651416f5e7461209ff1a93a98619e4.zip
Auto merge of #100540 - matthiaskrgr:rollup-734hkpt, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #100249 (Fix HorizonOS regression in FileTimes)
 - #100253 (Recover from mutable variable declaration where `mut` is placed before `let`)
 - #100482 (Add Duration rounding change to release note)
 - #100523 ([rustdoc] remove Clean trait)
 - #100524 (Impl `Debug` for some structs of rustbuild)
 - #100526 (Add tests for the drop behavior of some control flow constructs)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_parse/src/parser')
-rw-r--r--compiler/rustc_parse/src/parser/stmt.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/compiler/rustc_parse/src/parser/stmt.rs b/compiler/rustc_parse/src/parser/stmt.rs
index 6990d0782b7..d8b39a406cc 100644
--- a/compiler/rustc_parse/src/parser/stmt.rs
+++ b/compiler/rustc_parse/src/parser/stmt.rs
@@ -55,6 +55,19 @@ impl<'a> Parser<'a> {
             return Ok(Some(stmt.into_inner()));
         }
 
+        if self.token.is_keyword(kw::Mut) && self.is_keyword_ahead(1, &[kw::Let]) {
+            self.bump();
+            let mut_let_span = lo.to(self.token.span);
+            self.struct_span_err(mut_let_span, "invalid variable declaration")
+                .span_suggestion(
+                    mut_let_span,
+                    "switch the order of `mut` and `let`",
+                    "let mut",
+                    Applicability::MaybeIncorrect,
+                )
+                .emit();
+        }
+
         Ok(Some(if self.token.is_keyword(kw::Let) {
             self.parse_local_mk(lo, attrs, capture_semi, force_collect)?
         } else if self.is_kw_followed_by_ident(kw::Mut) {