mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-27 20:35:09 +00:00
refactor ascription
This commit is contained in:
parent
f843f23aba
commit
2a2815266b
3 changed files with 8 additions and 4 deletions
|
@ -13,8 +13,7 @@ fn const_or_static(p: &mut Parser, kw: SyntaxKind) {
|
||||||
p.bump();
|
p.bump();
|
||||||
p.eat(MUT_KW); // TODO: validator to forbid const mut
|
p.eat(MUT_KW); // TODO: validator to forbid const mut
|
||||||
name(p);
|
name(p);
|
||||||
p.expect(COLON);
|
types::ascription(p);
|
||||||
types::type_(p);
|
|
||||||
p.expect(EQ);
|
p.expect(EQ);
|
||||||
expressions::expr(p);
|
expressions::expr(p);
|
||||||
p.expect(SEMI);
|
p.expect(SEMI);
|
||||||
|
|
|
@ -279,8 +279,8 @@ fn fn_item(p: &mut Parser) {
|
||||||
let m = p.start();
|
let m = p.start();
|
||||||
p.bump();
|
p.bump();
|
||||||
patterns::pattern(p);
|
patterns::pattern(p);
|
||||||
if p.eat(COLON) {
|
if p.at(COLON) {
|
||||||
types::type_(p);
|
types::ascription(p);
|
||||||
}
|
}
|
||||||
if p.eat(EQ) {
|
if p.eat(EQ) {
|
||||||
expressions::expr(p);
|
expressions::expr(p);
|
||||||
|
|
|
@ -17,6 +17,11 @@ pub(super) fn type_(p: &mut Parser) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(super) fn ascription(p: &mut Parser) {
|
||||||
|
p.expect(COLON);
|
||||||
|
type_(p)
|
||||||
|
}
|
||||||
|
|
||||||
fn type_no_plus(p: &mut Parser) {
|
fn type_no_plus(p: &mut Parser) {
|
||||||
type_(p);
|
type_(p);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue