Add a note for *
and {}
usage on use
This commit is contained in:
parent
9155a9dae5
commit
d063745023
5 changed files with 24 additions and 1 deletions
|
@ -220,7 +220,22 @@ impl<'a> Parser<'a> {
|
||||||
let info = if self.eat_keyword(kw::Use) {
|
let info = if self.eat_keyword(kw::Use) {
|
||||||
// USE ITEM
|
// USE ITEM
|
||||||
let tree = self.parse_use_tree()?;
|
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)))
|
(Ident::invalid(), ItemKind::Use(P(tree)))
|
||||||
} else if self.check_fn_front_matter() {
|
} else if self.check_fn_front_matter() {
|
||||||
// FUNCTION ITEM
|
// FUNCTION ITEM
|
||||||
|
|
|
@ -3,6 +3,8 @@ error: expected `;`, found `::`
|
||||||
|
|
|
|
||||||
LL | use foo::{bar}::baz
|
LL | use foo::{bar}::baz
|
||||||
| ^^ expected `;`
|
| ^^ expected `;`
|
||||||
|
|
|
||||||
|
= note: glob-like brace syntax must be last on the path
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,8 @@ error: expected `;`, found keyword `as`
|
||||||
|
|
|
|
||||||
LL | use foo::{bar} as baz;
|
LL | use foo::{bar} as baz;
|
||||||
| ^^ expected `;`
|
| ^^ expected `;`
|
||||||
|
|
|
||||||
|
= note: glob-like brace syntax must be last on the path
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,8 @@ error: expected `;`, found `::`
|
||||||
|
|
|
|
||||||
LL | use foo::*::bar
|
LL | use foo::*::bar
|
||||||
| ^^ expected `;`
|
| ^^ expected `;`
|
||||||
|
|
|
||||||
|
= note: the wildcard token must be last on the path
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,8 @@ error: expected `;`, found keyword `as`
|
||||||
|
|
|
|
||||||
LL | use foo::* as baz;
|
LL | use foo::* as baz;
|
||||||
| ^^ expected `;`
|
| ^^ expected `;`
|
||||||
|
|
|
||||||
|
= note: the wildcard token must be last on the path
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue