We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
let
let const
1 parent 2af92bb commit accb8e3Copy full SHA for accb8e3
compiler/rustc_parse/src/parser/stmt.rs
@@ -247,6 +247,22 @@ impl<'a> Parser<'a> {
247
/// Parses a local variable declaration.
248
fn parse_local(&mut self, attrs: AttrVec) -> PResult<'a, P<Local>> {
249
let lo = self.prev_token.span;
250
+
251
+ if self.token.is_keyword(kw::Const) && self.look_ahead(1, |t| t.is_ident()) {
252
+ self.struct_span_err(
253
+ lo.to(self.token.span),
254
+ "`const` and `let` are mutually exclusive",
255
+ )
256
+ .span_suggestion(
257
258
+ "remove `let`",
259
+ "const",
260
+ Applicability::MaybeIncorrect,
261
262
+ .emit();
263
+ self.bump();
264
+ }
265
266
let (pat, colon) = self.parse_pat_before_ty(None, RecoverComma::Yes, "`let` bindings")?;
267
268
let (err, ty) = if colon {
0 commit comments