use super::*;
pub(super) fn konst(p: &mut Parser<'_>, m: Marker) {
p.eat(T![type]);
p.bump(T![const]);
const_or_static(p, m, true);
}
pub(super) fn static_(p: &mut Parser<'_>, m: Marker) {
p.bump(T![static]);
const_or_static(p, m, false);
}
fn const_or_static(p: &mut Parser<'_>, m: Marker, is_const: bool) {
p.eat(T![mut]);
if is_const && p.eat(T![_]) {
} else {
name(p);
}
if !is_const && p.at(T![<]) {
p.error("`static` may not have generic parameters");
}
generic_params::opt_generic_param_list(p);
if p.at(T![:]) {
types::ascription(p);
} else if is_const {
p.error("missing type for `const`");
} else {
p.error("missing type for `static`");
}
if p.eat(T![=]) {
expressions::expr(p);
}
if is_const {
generic_params::opt_where_clause(p);
}
p.expect(T![;]);
m.complete(p, if is_const { CONST } else { STATIC });
}