File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed
compiler/rustc_parse/src/parser Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -247,6 +247,22 @@ impl<'a> Parser<'a> {
247
247
/// Parses a local variable declaration.
248
248
fn parse_local ( & mut self , attrs : AttrVec ) -> PResult < ' a , P < Local > > {
249
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
+ lo. to ( self . token . span ) ,
258
+ "remove `let`" ,
259
+ "const" ,
260
+ Applicability :: MaybeIncorrect ,
261
+ )
262
+ . emit ( ) ;
263
+ self . bump ( ) ;
264
+ }
265
+
250
266
let ( pat, colon) = self . parse_pat_before_ty ( None , RecoverComma :: Yes , "`let` bindings" ) ?;
251
267
252
268
let ( err, ty) = if colon {
You can’t perform that action at this time.
0 commit comments