diff --git a/crates/parser/src/grammar/items.rs b/crates/parser/src/grammar/items.rs index 36d13cc977..7bfd9ef8c8 100644 --- a/crates/parser/src/grammar/items.rs +++ b/crates/parser/src/grammar/items.rs @@ -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); } diff --git a/crates/parser/test_data/parser/inline/ok/0012_type_item_where_clause.rast b/crates/parser/test_data/parser/inline/ok/0012_type_item_where_clause.rast index 7210b73895..31c87d1b30 100644 --- a/crates/parser/test_data/parser/inline/ok/0012_type_item_where_clause.rast +++ b/crates/parser/test_data/parser/inline/ok/0012_type_item_where_clause.rast @@ -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 " " @@ -23,11 +29,5 @@ SOURCE_FILE PATH_SEGMENT NAME_REF IDENT "Copy" - WHITESPACE " " - EQ "=" - WHITESPACE " " - TUPLE_TYPE - L_PAREN "(" - R_PAREN ")" SEMICOLON ";" WHITESPACE "\n" diff --git a/crates/parser/test_data/parser/inline/ok/0012_type_item_where_clause.rs b/crates/parser/test_data/parser/inline/ok/0012_type_item_where_clause.rs index a602d07f03..2d30e85218 100644 --- a/crates/parser/test_data/parser/inline/ok/0012_type_item_where_clause.rs +++ b/crates/parser/test_data/parser/inline/ok/0012_type_item_where_clause.rs @@ -1 +1 @@ -type Foo where Foo: Copy = (); +type Foo = () where Foo: Copy; diff --git a/crates/parser/test_data/parser/inline/ok/0199_type_item_where_clause_deprecated.rast b/crates/parser/test_data/parser/inline/ok/0199_type_item_where_clause_deprecated.rast new file mode 100644 index 0000000000..7210b73895 --- /dev/null +++ b/crates/parser/test_data/parser/inline/ok/0199_type_item_where_clause_deprecated.rast @@ -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" diff --git a/crates/parser/test_data/parser/inline/ok/0199_type_item_where_clause_deprecated.rs b/crates/parser/test_data/parser/inline/ok/0199_type_item_where_clause_deprecated.rs new file mode 100644 index 0000000000..a602d07f03 --- /dev/null +++ b/crates/parser/test_data/parser/inline/ok/0199_type_item_where_clause_deprecated.rs @@ -0,0 +1 @@ +type Foo where Foo: Copy = ();