diff options
| author | Dylan DPC <99973273+Dylan-DPC@users.noreply.github.com> | 2022-08-12 20:39:16 +0530 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-08-12 20:39:16 +0530 |
| commit | 9914c96f0676dc212e3a1e854f5ee8d477351a15 (patch) | |
| tree | 68ea532b882ad3e6f335c1cb22af60708d51c926 /compiler/rustc_parse/src/parser | |
| parent | 9e69dbce1993862539ef5fb4c53d09e0f1b73536 (diff) | |
| parent | 98518c2379d4bcf6909817758eb0bfd50557d51b (diff) | |
| download | rust-9914c96f0676dc212e3a1e854f5ee8d477351a15.tar.gz rust-9914c96f0676dc212e3a1e854f5ee8d477351a15.zip | |
Rollup merge of #100396 - chenyukang:fix-100394, r=petrochenkov
Suggest const and static for global variable Fixing #100394
Diffstat (limited to 'compiler/rustc_parse/src/parser')
| -rw-r--r-- | compiler/rustc_parse/src/parser/item.rs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/compiler/rustc_parse/src/parser/item.rs b/compiler/rustc_parse/src/parser/item.rs index 72c23776d33..197c0384898 100644 --- a/compiler/rustc_parse/src/parser/item.rs +++ b/compiler/rustc_parse/src/parser/item.rs @@ -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); } } |
