diff --git a/grammar.ron b/grammar.ron index 8e265323b4..c38bf654d5 100644 --- a/grammar.ron +++ b/grammar.ron @@ -114,6 +114,7 @@ Grammar( "ALIAS", "VISIBILITY", "TYPE_PARAM_LIST", + "WHERE_CLAUSE", "LIFETIME_PARAM", "TYPE_PARAM", "ABI", diff --git a/src/parser/grammar/type_params.rs b/src/parser/grammar/type_params.rs index 73c3cf8b8c..8f62a471cc 100644 --- a/src/parser/grammar/type_params.rs +++ b/src/parser/grammar/type_params.rs @@ -70,9 +70,11 @@ pub(super) fn list(p: &mut Parser) { pub(super) fn where_clause(p: &mut Parser) { if p.at(WHERE_KW) { + let m = p.start(); p.bump(); p.expect(IDENT); p.expect(COLON); p.expect(IDENT); + m.complete(p, WHERE_CLAUSE); } } diff --git a/src/syntax_kinds.rs b/src/syntax_kinds.rs index 501b940bbe..dc287f0f40 100644 --- a/src/syntax_kinds.rs +++ b/src/syntax_kinds.rs @@ -112,6 +112,7 @@ pub enum SyntaxKind { ALIAS, VISIBILITY, TYPE_PARAM_LIST, + WHERE_CLAUSE, LIFETIME_PARAM, TYPE_PARAM, ABI, @@ -234,6 +235,7 @@ impl SyntaxKind { ALIAS => &SyntaxInfo { name: "ALIAS" }, VISIBILITY => &SyntaxInfo { name: "VISIBILITY" }, TYPE_PARAM_LIST => &SyntaxInfo { name: "TYPE_PARAM_LIST" }, + WHERE_CLAUSE => &SyntaxInfo { name: "WHERE_CLAUSE" }, LIFETIME_PARAM => &SyntaxInfo { name: "LIFETIME_PARAM" }, TYPE_PARAM => &SyntaxInfo { name: "TYPE_PARAM" }, ABI => &SyntaxInfo { name: "ABI" }, diff --git a/tests/data/parser/inline/0016_type_item_where_clause.txt b/tests/data/parser/inline/0016_type_item_where_clause.txt index 28fcc7c0a3..ddd3358706 100644 --- a/tests/data/parser/inline/0016_type_item_where_clause.txt +++ b/tests/data/parser/inline/0016_type_item_where_clause.txt @@ -3,14 +3,15 @@ FILE@[0; 31) TYPE_KW@[0; 4) WHITESPACE@[4; 5) IDENT@[5; 8) "Foo" - WHITESPACE@[8; 9) - WHERE_KW@[9; 14) - WHITESPACE@[14; 15) - IDENT@[15; 18) "Foo" - COLON@[18; 19) - WHITESPACE@[19; 20) - IDENT@[20; 24) "Copy" - WHITESPACE@[24; 25) + WHERE_CLAUSE@[8; 25) + WHITESPACE@[8; 9) + WHERE_KW@[9; 14) + WHITESPACE@[14; 15) + IDENT@[15; 18) "Foo" + COLON@[18; 19) + WHITESPACE@[19; 20) + IDENT@[20; 24) "Copy" + WHITESPACE@[24; 25) EQ@[25; 26) WHITESPACE@[26; 27) L_PAREN@[27; 28)