mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-05 19:58:32 +00:00
Suggest removing let
if let const
is used
This commit is contained in:
parent
2af92bbf2e
commit
accb8e34c5
@ -247,6 +247,22 @@ impl<'a> Parser<'a> {
|
|||||||
/// Parses a local variable declaration.
|
/// Parses a local variable declaration.
|
||||||
fn parse_local(&mut self, attrs: AttrVec) -> PResult<'a, P<Local>> {
|
fn parse_local(&mut self, attrs: AttrVec) -> PResult<'a, P<Local>> {
|
||||||
let lo = self.prev_token.span;
|
let lo = self.prev_token.span;
|
||||||
|
|
||||||
|
if self.token.is_keyword(kw::Const) && self.look_ahead(1, |t| t.is_ident()) {
|
||||||
|
self.struct_span_err(
|
||||||
|
lo.to(self.token.span),
|
||||||
|
"`const` and `let` are mutually exclusive",
|
||||||
|
)
|
||||||
|
.span_suggestion(
|
||||||
|
lo.to(self.token.span),
|
||||||
|
"remove `let`",
|
||||||
|
"const",
|
||||||
|
Applicability::MaybeIncorrect,
|
||||||
|
)
|
||||||
|
.emit();
|
||||||
|
self.bump();
|
||||||
|
}
|
||||||
|
|
||||||
let (pat, colon) = self.parse_pat_before_ty(None, RecoverComma::Yes, "`let` bindings")?;
|
let (pat, colon) = self.parse_pat_before_ty(None, RecoverComma::Yes, "`let` bindings")?;
|
||||||
|
|
||||||
let (err, ty) = if colon {
|
let (err, ty) = if colon {
|
||||||
|
Loading…
Reference in New Issue
Block a user