mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 04:53:34 +00:00
Safer errors
This commit is contained in:
parent
c1a7b72fb7
commit
51f7f937a5
3 changed files with 22 additions and 21 deletions
|
@ -129,7 +129,7 @@ fn name(p: &mut Parser) {
|
||||||
p.bump();
|
p.bump();
|
||||||
m.complete(p, NAME);
|
m.complete(p, NAME);
|
||||||
} else {
|
} else {
|
||||||
p.error("expected a name");
|
p.err_and_bump("expected a name");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,7 +139,7 @@ fn name_ref(p: &mut Parser) {
|
||||||
p.bump();
|
p.bump();
|
||||||
m.complete(p, NAME_REF);
|
m.complete(p, NAME_REF);
|
||||||
} else {
|
} else {
|
||||||
p.error("expected identifier");
|
p.err_and_bump("expected identifier");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -117,11 +117,8 @@ fn struct_pat_fields(p: &mut Parser) {
|
||||||
p.bump();
|
p.bump();
|
||||||
pattern(p);
|
pattern(p);
|
||||||
}
|
}
|
||||||
REF_KW | MUT_KW | IDENT => {
|
|
||||||
bind_pat(p, false);
|
|
||||||
},
|
|
||||||
_ => {
|
_ => {
|
||||||
p.err_and_bump("expected ident");
|
bind_pat(p, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !p.at(R_CURLY) {
|
if !p.at(R_CURLY) {
|
||||||
|
|
|
@ -97,19 +97,21 @@ FILE@[0; 164)
|
||||||
WHITESPACE@[125; 126)
|
WHITESPACE@[125; 126)
|
||||||
L_CURLY@[126; 127)
|
L_CURLY@[126; 127)
|
||||||
WHITESPACE@[127; 132)
|
WHITESPACE@[127; 132)
|
||||||
err: `expected ident`
|
err: `expected a name`
|
||||||
ERROR@[132; 134)
|
BIND_PAT@[132; 134)
|
||||||
FN_KW@[132; 134)
|
ERROR@[132; 134)
|
||||||
err: `expected COMMA`
|
FN_KW@[132; 134)
|
||||||
|
err: `expected COMMA`
|
||||||
WHITESPACE@[134; 135)
|
WHITESPACE@[134; 135)
|
||||||
BIND_PAT@[135; 147)
|
BIND_PAT@[135; 147)
|
||||||
NAME@[135; 147)
|
NAME@[135; 147)
|
||||||
IDENT@[135; 147) "fn_with_expr"
|
IDENT@[135; 147) "fn_with_expr"
|
||||||
err: `expected COMMA`
|
err: `expected COMMA`
|
||||||
err: `expected ident`
|
err: `expected a name`
|
||||||
ERROR@[147; 148)
|
BIND_PAT@[147; 148)
|
||||||
L_PAREN@[147; 148)
|
ERROR@[147; 148)
|
||||||
err: `expected COMMA`
|
L_PAREN@[147; 148)
|
||||||
|
err: `expected COMMA`
|
||||||
IDENT@[148; 149) "x"
|
IDENT@[148; 149) "x"
|
||||||
COLON@[149; 150)
|
COLON@[149; 150)
|
||||||
WHITESPACE@[150; 151)
|
WHITESPACE@[150; 151)
|
||||||
|
@ -128,13 +130,15 @@ FILE@[0; 164)
|
||||||
INT_NUMBER@[157; 158) "1"
|
INT_NUMBER@[157; 158) "1"
|
||||||
R_BRACK@[158; 159)
|
R_BRACK@[158; 159)
|
||||||
err: `expected COMMA`
|
err: `expected COMMA`
|
||||||
err: `expected ident`
|
err: `expected a name`
|
||||||
ERROR@[159; 160)
|
BIND_PAT@[159; 160)
|
||||||
R_PAREN@[159; 160)
|
ERROR@[159; 160)
|
||||||
err: `expected COMMA`
|
R_PAREN@[159; 160)
|
||||||
err: `expected ident`
|
err: `expected COMMA`
|
||||||
ERROR@[160; 161)
|
err: `expected a name`
|
||||||
SEMI@[160; 161)
|
BIND_PAT@[160; 161)
|
||||||
|
ERROR@[160; 161)
|
||||||
|
SEMI@[160; 161)
|
||||||
WHITESPACE@[161; 162)
|
WHITESPACE@[161; 162)
|
||||||
R_CURLY@[162; 163)
|
R_CURLY@[162; 163)
|
||||||
err: `expected COLON`
|
err: `expected COLON`
|
||||||
|
|
Loading…
Reference in a new issue