Skip to content

Commit 2af92bb

Browse files
committed
Suggest removing let if const let is used
1 parent dcb444a commit 2af92bb

File tree

1 file changed

+10
-0
lines changed
  • compiler/rustc_parse/src/parser

1 file changed

+10
-0
lines changed

compiler/rustc_parse/src/parser/item.rs

+10
Original file line numberDiff line numberDiff line change
@@ -1124,6 +1124,16 @@ impl<'a> Parser<'a> {
11241124
Applicability::MaybeIncorrect,
11251125
)
11261126
.emit();
1127+
} else if self.eat_keyword(kw::Let) {
1128+
let span = self.prev_token.span;
1129+
self.struct_span_err(const_span.to(span), "`const` and `let` are mutually exclusive")
1130+
.span_suggestion(
1131+
const_span.to(span),
1132+
"remove `let`",
1133+
"const",
1134+
Applicability::MaybeIncorrect,
1135+
)
1136+
.emit();
11271137
}
11281138
}
11291139

0 commit comments

Comments
 (0)