Skip to content

Commit aaadaa4

Browse files
committed
internal: more focused trait item parsing tests
1 parent 6cb33c3 commit aaadaa4

13 files changed

+242
-228
lines changed

crates/parser/src/grammar/items/traits.rs

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,39 @@
11
use super::*;
22

33
// test trait_item
4-
// trait T<U>: Hash + Clone where U: Copy {}
5-
// trait X<U: Debug + Display>: Hash + Clone where U: Copy {}
4+
// trait T { fn new() -> Self; }
65
pub(super) fn trait_(p: &mut Parser, m: Marker) {
7-
assert!(p.at(T![trait]));
86
p.bump(T![trait]);
97
name_r(p, ITEM_RECOVERY_SET);
8+
9+
// test trait_item_generic_params
10+
// trait X<U: Debug + Display> {}
1011
type_params::opt_generic_param_list(p);
11-
// test trait_alias
12-
// trait Z<U> = T<U>;
13-
// trait Z<U> = T<U> where U: Copy;
14-
// trait Z<U> = where Self: T<U>;
12+
1513
if p.eat(T![=]) {
14+
// test trait_alias
15+
// trait Z<U> = T<U>;
1616
type_params::bounds_without_colon(p);
17+
18+
// test trait_alias_where_clause
19+
// trait Z<U> = T<U> where U: Copy;
20+
// trait Z<U> = where Self: T<U>;
1721
type_params::opt_where_clause(p);
1822
p.expect(T![;]);
1923
m.complete(p, TRAIT);
2024
return;
2125
}
26+
2227
if p.at(T![:]) {
28+
// test trait_item_bounds
29+
// trait T: Hash + Clone {}
2330
type_params::bounds(p);
2431
}
32+
33+
// test trait_item_where_clause
34+
// trait T where Self: Copy {}
2535
type_params::opt_where_clause(p);
36+
2637
if p.at(T!['{']) {
2738
assoc_item_list(p);
2839
} else {
Lines changed: 27 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -1,125 +1,31 @@
1-
SOURCE_FILE@0..101
2-
TRAIT@0..41
1+
SOURCE_FILE@0..30
2+
TRAIT@0..29
33
44
55
66
7-
8-
9-
10-
11-
12-
13-
14-
15-
16-
17-
18-
19-
20-
21-
22-
23-
24-
25-
26-
27-
28-
29-
30-
31-
32-
33-
34-
35-
36-
37-
38-
39-
40-
41-
42-
43-
44-
45-
46-
47-
48-
49-
50-
51-
52-
53-
54-
55-
56-
57-
58-
59-
60-
61-
62-
63-
64-
65-
66-
67-
68-
69-
70-
71-
72-
73-
74-
75-
76-
77-
78-
79-
80-
81-
82-
83-
84-
85-
86-
87-
88-
89-
90-
91-
92-
93-
94-
95-
96-
97-
98-
99-
100-
101-
102-
103-
104-
105-
106-
107-
108-
109-
110-
111-
112-
113-
114-
115-
116-
117-
118-
119-
120-
121-
122-
123-
124-
125-
7+
8+
9+
10+
11+
12+
13+
14+
15+
16+
17+
18+
19+
20+
21+
22+
23+
24+
25+
26+
27+
28+
29+
30+
31+
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
trait T<U>: Hash + Clone where U: Copy {}
2-
trait X<U: Debug + Display>: Hash + Clone where U: Copy {}
1+
trait T { fn new() -> Self; }
Lines changed: 1 addition & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
SOURCE_FILE@0..83
1+
SOURCE_FILE@0..19
22
33
44
@@ -31,98 +31,3 @@ [email protected]
3131
3232
3333
34-
35-
36-
37-
38-
39-
40-
41-
42-
43-
44-
45-
46-
47-
48-
49-
50-
51-
52-
53-
54-
55-
56-
57-
58-
59-
60-
61-
62-
63-
64-
65-
66-
67-
68-
69-
70-
71-
72-
73-
74-
75-
76-
77-
78-
79-
80-
81-
82-
83-
84-
85-
86-
87-
88-
89-
90-
91-
92-
93-
94-
95-
96-
97-
98-
99-
100-
101-
102-
103-
104-
105-
106-
107-
108-
109-
110-
111-
112-
113-
114-
115-
116-
117-
118-
119-
120-
121-
122-
123-
124-
125-
126-
127-
128-
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
11
trait Z<U> = T<U>;
2-
trait Z<U> = T<U> where U: Copy;
3-
trait Z<U> = where Self: T<U>;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
trait X<U: Debug + Display> {}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
trait T: Hash + Clone {}

0 commit comments

Comments
 (0)