about summary refs log tree commit diff
path: root/compiler/rustc_parse/src/parser
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-01-08 09:51:26 +0000
committerbors <bors@rust-lang.org>2021-01-08 09:51:26 +0000
commit3d8608a8638fabc46e83acc0626d4cf2782f0702 (patch)
tree72b6041060d6f7e5e24933ee7a8079e58cf8a6b4 /compiler/rustc_parse/src/parser
parent569e542f9f8792268ce02fc1ad7c00b449b965dc (diff)
parentd063745023441918c409a66b2607b057163b4144 (diff)
downloadrust-3d8608a8638fabc46e83acc0626d4cf2782f0702.tar.gz
rust-3d8608a8638fabc46e83acc0626d4cf2782f0702.zip
Auto merge of #80535 - JohnTitor:improve-use-diag, r=estebank
Add a note for `*` and `{}` usage on `use`

Closes #80333
Diffstat (limited to 'compiler/rustc_parse/src/parser')
-rw-r--r--compiler/rustc_parse/src/parser/item.rs17
1 files changed, 16 insertions, 1 deletions
diff --git a/compiler/rustc_parse/src/parser/item.rs b/compiler/rustc_parse/src/parser/item.rs
index e49b1a54e9b..4fcc9edb7d9 100644
--- a/compiler/rustc_parse/src/parser/item.rs
+++ b/compiler/rustc_parse/src/parser/item.rs
@@ -220,7 +220,22 @@ impl<'a> Parser<'a> {
         let info = if self.eat_keyword(kw::Use) {
             // USE ITEM
             let tree = self.parse_use_tree()?;
-            self.expect_semi()?;
+
+            // If wildcard or glob-like brace syntax doesn't have `;`,
+            // the user may not know `*` or `{}` should be the last.
+            if let Err(mut e) = self.expect_semi() {
+                match tree.kind {
+                    UseTreeKind::Glob => {
+                        e.note("the wildcard token must be last on the path").emit();
+                    }
+                    UseTreeKind::Nested(..) => {
+                        e.note("glob-like brace syntax must be last on the path").emit();
+                    }
+                    _ => (),
+                }
+                return Err(e);
+            }
+
             (Ident::invalid(), ItemKind::Use(P(tree)))
         } else if self.check_fn_front_matter() {
             // FUNCTION ITEM