Add support for new where clause location in associated types.

A recent Rust nightly changed it: https://github.com/rust-lang/rust/issues/89122

This allows both the old and new location.
This commit is contained in:
Dario Nieuwenhuis 2022-03-10 18:10:03 +01:00
parent 356c507357
commit 49d1207775
5 changed files with 47 additions and 8 deletions

View file

@ -290,12 +290,17 @@ fn type_alias(p: &mut Parser, m: Marker) {
generic_params::bounds(p); generic_params::bounds(p);
} }
// test type_item_where_clause // test type_item_where_clause_deprecated
// type Foo where Foo: Copy = (); // type Foo where Foo: Copy = ();
generic_params::opt_where_clause(p); generic_params::opt_where_clause(p);
if p.eat(T![=]) { if p.eat(T![=]) {
types::type_(p); types::type_(p);
} }
// test type_item_where_clause
// type Foo = () where Foo: Copy;
generic_params::opt_where_clause(p);
p.expect(T![;]); p.expect(T![;]);
m.complete(p, TYPE_ALIAS); m.complete(p, TYPE_ALIAS);
} }

View file

@ -5,6 +5,12 @@ SOURCE_FILE
NAME NAME
IDENT "Foo" IDENT "Foo"
WHITESPACE " " WHITESPACE " "
EQ "="
WHITESPACE " "
TUPLE_TYPE
L_PAREN "("
R_PAREN ")"
WHITESPACE " "
WHERE_CLAUSE WHERE_CLAUSE
WHERE_KW "where" WHERE_KW "where"
WHITESPACE " " WHITESPACE " "
@ -23,11 +29,5 @@ SOURCE_FILE
PATH_SEGMENT PATH_SEGMENT
NAME_REF NAME_REF
IDENT "Copy" IDENT "Copy"
WHITESPACE " "
EQ "="
WHITESPACE " "
TUPLE_TYPE
L_PAREN "("
R_PAREN ")"
SEMICOLON ";" SEMICOLON ";"
WHITESPACE "\n" WHITESPACE "\n"

View file

@ -1 +1 @@
type Foo where Foo: Copy = (); type Foo = () where Foo: Copy;

View file

@ -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"

View file

@ -0,0 +1 @@
type Foo where Foo: Copy = ();