Skip to content

Commit 1567bbb

Browse files
committed
minor: more focusted tests
1 parent a6f17f7 commit 1567bbb

File tree

7 files changed

+107
-156
lines changed

7 files changed

+107
-156
lines changed

crates/parser/src/grammar/expressions.rs

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -115,55 +115,46 @@ pub(super) fn stmt(p: &mut Parser, with_semi: StmtWithSemi, prefer_expr: bool) {
115115
// }
116116

117117
match with_semi {
118+
StmtWithSemi::No => (),
119+
StmtWithSemi::Optional => {
120+
p.eat(T![;]);
121+
}
118122
StmtWithSemi::Yes => {
119123
if blocklike.is_block() {
120124
p.eat(T![;]);
121125
} else {
122126
p.expect(T![;]);
123127
}
124128
}
125-
StmtWithSemi::No => {}
126-
StmtWithSemi::Optional => {
127-
if p.at(T![;]) {
128-
p.eat(T![;]);
129-
}
130-
}
131129
}
132130

133131
m.complete(p, EXPR_STMT);
134132
}
135133

136134
// test let_stmt
137-
// fn foo() {
138-
// let a;
139-
// let b: i32;
140-
// let c = 92;
141-
// let d: i32 = 92;
142-
// let e: !;
143-
// let _: ! = {};
144-
// let f = #[attr]||{};
145-
// }
135+
// fn f() { let x: i32 = 92; }
146136
fn let_stmt(p: &mut Parser, m: Marker, with_semi: StmtWithSemi) {
147-
assert!(p.at(T![let]));
148137
p.bump(T![let]);
149138
patterns::pattern(p);
150139
if p.at(T![:]) {
140+
// test let_stmt_ascription
141+
// fn f() { let x: i32; }
151142
types::ascription(p);
152143
}
153144
if p.eat(T![=]) {
145+
// test let_stmt_init
146+
// fn f() { let x = 92; }
154147
expressions::expr_with_attrs(p);
155148
}
156149

157150
match with_semi {
151+
StmtWithSemi::No => (),
152+
StmtWithSemi::Optional => {
153+
p.eat(T![;]);
154+
}
158155
StmtWithSemi::Yes => {
159156
p.expect(T![;]);
160157
}
161-
StmtWithSemi::No => {}
162-
StmtWithSemi::Optional => {
163-
if p.at(T![;]) {
164-
p.eat(T![;]);
165-
}
166-
}
167158
}
168159
m.complete(p, LET_STMT);
169160
}
Lines changed: 33 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -1,127 +1,35 @@
1-
SOURCE_FILE@0..135
2-
FN@0..134
1+
SOURCE_FILE@0..28
2+
FN@0..27
33
44
5-
6-
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-
126-
127-
5+
6+
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+
Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1 @@
1-
fn foo() {
2-
let a;
3-
let b: i32;
4-
let c = 92;
5-
let d: i32 = 92;
6-
let e: !;
7-
let _: ! = {};
8-
let f = #[attr]||{};
9-
}
1+
fn f() { let x: i32 = 92; }
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
fn f() { let x = 92; }
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
fn f() { let x: i32; }

0 commit comments

Comments
 (0)