about summary refs log tree commit diff
path: root/compiler/rustc_parse/src/parser/item.rs
diff options
context:
space:
mode:
authorGurinder Singh <gurinder.singh@1e.com>2023-09-06 09:05:07 +0530
committerGurinder Singh <gurinder.singh@1e.com>2023-09-06 09:05:07 +0530
commit6a286e775c51efb5f05bb98ed2df6b9a974574ad (patch)
tree09fc31965920da56224d419efa11a861eb49dc68 /compiler/rustc_parse/src/parser/item.rs
parent9dc11a13fa848c1b09b7248c540528190dcb79c5 (diff)
downloadrust-6a286e775c51efb5f05bb98ed2df6b9a974574ad.tar.gz
rust-6a286e775c51efb5f05bb98ed2df6b9a974574ad.zip
Add explanatory note to 'expected item' error
Diffstat (limited to 'compiler/rustc_parse/src/parser/item.rs')
-rw-r--r--compiler/rustc_parse/src/parser/item.rs12
1 files changed, 8 insertions, 4 deletions
diff --git a/compiler/rustc_parse/src/parser/item.rs b/compiler/rustc_parse/src/parser/item.rs
index 233c7016417..aad4edaba90 100644
--- a/compiler/rustc_parse/src/parser/item.rs
+++ b/compiler/rustc_parse/src/parser/item.rs
@@ -73,12 +73,16 @@ 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);
-                let label = if self.is_kw_followed_by_ident(kw::Let) {
-                    "consider using `const` or `static` instead of `let` for global variables"
+                let span = self.token.span;
+                if self.is_kw_followed_by_ident(kw::Let) {
+                    err.span_label(
+                        span,
+                        "consider using `const` or `static` instead of `let` for global variables",
+                    );
                 } else {
-                    "expected item"
+                    err.span_label(span, "expected item")
+                        .note("for a full list of items that can appear in modules, see <https://doc.rust-lang.org/reference/items.html>");
                 };
-                err.span_label(self.token.span, label);
                 return Err(err);
             }
         }