Give path segment type anchors their own grammar rule

This commit is contained in:
Lukas Wirth 2025-06-04 11:30:43 +02:00
parent d2164fe08b
commit 7c3de05e3a
14 changed files with 223 additions and 158 deletions

View file

@ -89,7 +89,9 @@ fn path_segment(p: &mut Parser<'_>, mode: Mode, first: bool) -> Option<Completed
// test qual_paths
// type X = <A as B>::Output;
// fn foo() { <usize as Default>::default(); }
if first && p.eat(T![<]) {
if first && p.at(T![<]) {
let m = p.start();
p.bump(T![<]);
// test_err angled_path_without_qual
// type X = <()>;
// type Y = <A as B>;
@ -102,6 +104,7 @@ fn path_segment(p: &mut Parser<'_>, mode: Mode, first: bool) -> Option<Completed
}
}
p.expect(T![>]);
m.complete(p, TYPE_ANCHOR);
if !p.at(T![::]) {
p.error("expected `::`");
}

View file

@ -291,6 +291,7 @@ pub enum SyntaxKind {
TUPLE_STRUCT_PAT,
TUPLE_TYPE,
TYPE_ALIAS,
TYPE_ANCHOR,
TYPE_ARG,
TYPE_BOUND,
TYPE_BOUND_LIST,
@ -463,6 +464,7 @@ impl SyntaxKind {
| TUPLE_STRUCT_PAT
| TUPLE_TYPE
| TYPE_ALIAS
| TYPE_ANCHOR
| TYPE_ARG
| TYPE_BOUND
| TYPE_BOUND_LIST