Skip to content

Commit 1feb8e8

Browse files
committed
minor: cleanup const parsing
1 parent 46326b8 commit 1feb8e8

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
use super::*;
22

3-
pub(super) fn static_(p: &mut Parser, m: Marker) {
4-
const_or_static(p, m, T![static], STATIC)
3+
pub(super) fn konst(p: &mut Parser, m: Marker) {
4+
p.bump(T![const]);
5+
const_or_static(p, m, true)
56
}
67

7-
pub(super) fn konst(p: &mut Parser, m: Marker) {
8-
const_or_static(p, m, T![const], CONST)
8+
pub(super) fn static_(p: &mut Parser, m: Marker) {
9+
p.bump(T![static]);
10+
const_or_static(p, m, false)
911
}
1012

11-
fn const_or_static(p: &mut Parser, m: Marker, kw: SyntaxKind, def: SyntaxKind) {
12-
assert!(p.at(kw));
13-
p.bump(kw);
13+
fn const_or_static(p: &mut Parser, m: Marker, is_const: bool) {
1414
p.eat(T![mut]);
1515

1616
// Allow `_` in place of an identifier in a `const`.
17-
let is_const_underscore = kw == T![const] && p.eat(T![_]);
17+
let is_const_underscore = is_const && p.eat(T![_]);
1818
if !is_const_underscore {
1919
name(p);
2020
}
@@ -30,5 +30,5 @@ fn const_or_static(p: &mut Parser, m: Marker, kw: SyntaxKind, def: SyntaxKind) {
3030
expressions::expr(p);
3131
}
3232
p.expect(T![;]);
33-
m.complete(p, def);
33+
m.complete(p, if is_const { CONST } else { STATIC });
3434
}

0 commit comments

Comments
 (0)