Skip to content

Accept path keywords and empty groups in use trees - #33

Closed
faysou wants to merge 3 commits into
aacebo:masterfrom
faysou:fix-use-tree-syntax
Closed

faysou wants to merge 3 commits into
aacebo:masterfrom
faysou:fix-use-tree-syntax

Conversation

@faysou

@faysou faysou commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

Parse path keywords in use trees and accept empty groups such as use a::{};. Preserve trailing commas in use groups and angle-bracket lists.

The use-tree and generics test modules pass.

Related to #25.

@faysou faysou mentioned this pull request Nov 20, 2026
`use crate::a;`, `use super::{A, B};`, and `use a::{self, b};` failed
with "expected ident, received "crate"": the use tree parsers accepted
only identifier segments, while the lexer produces these path keywords
as keyword tokens. Inside a module the failure was silent, because the
item list stopped at the `use` item: `mod m { use super::A; }` parsed as
an empty module.

Use path, name, and rename segments now accept the path keywords, stored
as identifiers with the keyword's text.
`use a::{b, c,};`, `Foo<A, B,>`, and `fn f<T: A,>()` failed to parse,
since the lists required a value after every comma. Rust accepts a
trailing comma in each.

`List::parse_nonempty_until::<E>` parses one or more values with an
optional trailing separator before the token `E`; generic arguments and
generic parameters use it before `>`, and use groups parse a full,
possibly trailing, list, which also reports a missing comma
(`use a::{b c};`) as "expected punctuation". The skippers follow.
`use a::{};` failed with "expected Ident": a use group was recognized
only when a use tree began inside its braces, so an empty group fell
through to a use name. Rust accepts the empty group, which imports
nothing.

Any brace-delimited group in a use tree is now a use group, and the
group's skipper accepts one with no trees.
@faysou
faysou force-pushed the fix-use-tree-syntax branch from 44498b3 to 32c82ae Compare November 21, 2026 07:10
@faysou faysou closed this Nov 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant