Skip to content

Add support for new where clause location in associated types. #11672

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion crates/parser/src/grammar/items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,12 +290,17 @@ fn type_alias(p: &mut Parser, m: Marker) {
generic_params::bounds(p);
}

// test type_item_where_clause
// test type_item_where_clause_deprecated
// type Foo where Foo: Copy = ();
generic_params::opt_where_clause(p);
if p.eat(T![=]) {
types::type_(p);
}

// test type_item_where_clause
// type Foo = () where Foo: Copy;
generic_params::opt_where_clause(p);

p.expect(T![;]);
m.complete(p, TYPE_ALIAS);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ SOURCE_FILE
NAME
IDENT "Foo"
WHITESPACE " "
EQ "="
WHITESPACE " "
TUPLE_TYPE
L_PAREN "("
R_PAREN ")"
WHITESPACE " "
WHERE_CLAUSE
WHERE_KW "where"
WHITESPACE " "
Expand All @@ -23,11 +29,5 @@ SOURCE_FILE
PATH_SEGMENT
NAME_REF
IDENT "Copy"
WHITESPACE " "
EQ "="
WHITESPACE " "
TUPLE_TYPE
L_PAREN "("
R_PAREN ")"
SEMICOLON ";"
WHITESPACE "\n"
Original file line number Diff line number Diff line change
@@ -1 +1 @@
type Foo where Foo: Copy = ();
type Foo = () where Foo: Copy;
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
SOURCE_FILE
TYPE_ALIAS
TYPE_KW "type"
WHITESPACE " "
NAME
IDENT "Foo"
WHITESPACE " "
WHERE_CLAUSE
WHERE_KW "where"
WHITESPACE " "
WHERE_PRED
PATH_TYPE
PATH
PATH_SEGMENT
NAME_REF
IDENT "Foo"
COLON ":"
WHITESPACE " "
TYPE_BOUND_LIST
TYPE_BOUND
PATH_TYPE
PATH
PATH_SEGMENT
NAME_REF
IDENT "Copy"
WHITESPACE " "
EQ "="
WHITESPACE " "
TUPLE_TYPE
L_PAREN "("
R_PAREN ")"
SEMICOLON ";"
WHITESPACE "\n"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
type Foo where Foo: Copy = ();