Skip to content

Commit e963443

Browse files
bors[bot]Dirbaio
andauthored
Merge #11672
11672: Add support for new `where` clause location in associated types. r=Veykril a=Dirbaio A recent Rust nightly changed it: rust-lang/rust#89122 This allows both the old and new location. Fixes #11651 Co-authored-by: Dario Nieuwenhuis <[email protected]>
2 parents 356c507 + 49d1207 commit e963443

File tree

5 files changed

+47
-8
lines changed

5 files changed

+47
-8
lines changed

crates/parser/src/grammar/items.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -290,12 +290,17 @@ fn type_alias(p: &mut Parser, m: Marker) {
290290
generic_params::bounds(p);
291291
}
292292

293-
// test type_item_where_clause
293+
// test type_item_where_clause_deprecated
294294
// type Foo where Foo: Copy = ();
295295
generic_params::opt_where_clause(p);
296296
if p.eat(T![=]) {
297297
types::type_(p);
298298
}
299+
300+
// test type_item_where_clause
301+
// type Foo = () where Foo: Copy;
302+
generic_params::opt_where_clause(p);
303+
299304
p.expect(T![;]);
300305
m.complete(p, TYPE_ALIAS);
301306
}

crates/parser/test_data/parser/inline/ok/0012_type_item_where_clause.rast

+6-6
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ SOURCE_FILE
55
NAME
66
IDENT "Foo"
77
WHITESPACE " "
8+
EQ "="
9+
WHITESPACE " "
10+
TUPLE_TYPE
11+
L_PAREN "("
12+
R_PAREN ")"
13+
WHITESPACE " "
814
WHERE_CLAUSE
915
WHERE_KW "where"
1016
WHITESPACE " "
@@ -23,11 +29,5 @@ SOURCE_FILE
2329
PATH_SEGMENT
2430
NAME_REF
2531
IDENT "Copy"
26-
WHITESPACE " "
27-
EQ "="
28-
WHITESPACE " "
29-
TUPLE_TYPE
30-
L_PAREN "("
31-
R_PAREN ")"
3232
SEMICOLON ";"
3333
WHITESPACE "\n"
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
type Foo where Foo: Copy = ();
1+
type Foo = () where Foo: Copy;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
SOURCE_FILE
2+
TYPE_ALIAS
3+
TYPE_KW "type"
4+
WHITESPACE " "
5+
NAME
6+
IDENT "Foo"
7+
WHITESPACE " "
8+
WHERE_CLAUSE
9+
WHERE_KW "where"
10+
WHITESPACE " "
11+
WHERE_PRED
12+
PATH_TYPE
13+
PATH
14+
PATH_SEGMENT
15+
NAME_REF
16+
IDENT "Foo"
17+
COLON ":"
18+
WHITESPACE " "
19+
TYPE_BOUND_LIST
20+
TYPE_BOUND
21+
PATH_TYPE
22+
PATH
23+
PATH_SEGMENT
24+
NAME_REF
25+
IDENT "Copy"
26+
WHITESPACE " "
27+
EQ "="
28+
WHITESPACE " "
29+
TUPLE_TYPE
30+
L_PAREN "("
31+
R_PAREN ")"
32+
SEMICOLON ";"
33+
WHITESPACE "\n"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
type Foo where Foo: Copy = ();

0 commit comments

Comments
 (0)