Rollup merge of #100396 - chenyukang:fix-100394, r=petrochenkov
Suggest const and static for global variable Fixing #100394
This commit is contained in:
commit
9914c96f06
3 changed files with 20 additions and 1 deletions
|
@ -68,7 +68,12 @@ impl<'a> Parser<'a> {
|
|||
if !self.maybe_consume_incorrect_semicolon(&items) {
|
||||
let msg = &format!("expected item, found {token_str}");
|
||||
let mut err = self.struct_span_err(self.token.span, msg);
|
||||
err.span_label(self.token.span, "expected item");
|
||||
let label = if self.is_kw_followed_by_ident(kw::Let) {
|
||||
"consider using `const` or `static` instead of `let` for global variables"
|
||||
} else {
|
||||
"expected item"
|
||||
};
|
||||
err.span_label(self.token.span, label);
|
||||
return Err(err);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue