Skip to content

Commit 1a4ca4e

Browse files
committed
Add AST node for trait alias
1 parent bed2c1c commit 1a4ca4e

File tree

7 files changed

+12
-8
lines changed

7 files changed

+12
-8
lines changed

crates/parser/src/grammar/items/traits.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub(super) fn trait_(p: &mut Parser<'_>, m: Marker) {
2020
// trait Z<U> = where Self: T<U>;
2121
generic_params::opt_where_clause(p);
2222
p.expect(T![;]);
23-
m.complete(p, TRAIT);
23+
m.complete(p, TRAIT_ALIAS);
2424
return;
2525
}
2626

crates/parser/src/syntax_kind/generated.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ pub enum SyntaxKind {
135135
STATIC,
136136
CONST,
137137
TRAIT,
138+
TRAIT_ALIAS,
138139
IMPL,
139140
TYPE_ALIAS,
140141
MACRO_CALL,

crates/parser/test_data/parser/inline/ok/0151_trait_alias.rast

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
SOURCE_FILE
2-
TRAIT
2+
TRAIT_ALIAS
33
TRAIT_KW "trait"
44
WHITESPACE " "
55
NAME

crates/parser/test_data/parser/inline/ok/0177_trait_alias_where_clause.rast

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
SOURCE_FILE
2-
TRAIT
2+
TRAIT_ALIAS
33
TRAIT_KW "trait"
44
WHITESPACE " "
55
NAME
@@ -50,7 +50,7 @@ SOURCE_FILE
5050
IDENT "Copy"
5151
SEMICOLON ";"
5252
WHITESPACE "\n"
53-
TRAIT
53+
TRAIT_ALIAS
5454
TRAIT_KW "trait"
5555
WHITESPACE " "
5656
NAME

crates/syntax/rust.ungram

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -240,10 +240,11 @@ Trait =
240240
Attr* Visibility?
241241
'unsafe'? 'auto'?
242242
'trait' Name GenericParamList?
243-
(
244-
(':' TypeBoundList?)? WhereClause? AssocItemList
245-
| '=' TypeBoundList? WhereClause? ';'
246-
)
243+
(':' TypeBoundList?)? WhereClause? AssocItemList
244+
245+
TraitAlias =
246+
Attr* Visibility?
247+
'trait' Name GenericParamList? '=' TypeBoundList? WhereClause? ';'
247248

248249
AssocItemList =
249250
'{' Attr* AssocItem* '}'

crates/syntax/src/tests/ast_src.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ pub(crate) const KINDS_SRC: KindsSrc<'_> = KindsSrc {
8686
"STATIC",
8787
"CONST",
8888
"TRAIT",
89+
"TRAIT_ALIAS",
8990
"IMPL",
9091
"TYPE_ALIAS",
9192
"MACRO_CALL",

crates/syntax/src/tests/sourcegen_ast.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -783,6 +783,7 @@ fn extract_struct_traits(ast: &mut AstSrc) {
783783
"Enum",
784784
"Variant",
785785
"Trait",
786+
"TraitAlias",
786787
"Module",
787788
"Static",
788789
"Const",

0 commit comments

Comments
 (0)