mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 14:21:44 +00:00
improve error recovery
parse the contents of error block as an expression
This commit is contained in:
parent
3000b13df2
commit
77f2381eea
4 changed files with 77 additions and 59 deletions
|
@ -182,21 +182,11 @@ fn name_ref(p: &mut Parser) {
|
|||
}
|
||||
|
||||
fn error_block(p: &mut Parser, message: &str) {
|
||||
go(p, Some(message));
|
||||
fn go(p: &mut Parser, message: Option<&str>) {
|
||||
assert!(p.at(L_CURLY));
|
||||
let m = p.start();
|
||||
if let Some(message) = message {
|
||||
p.error(message);
|
||||
}
|
||||
p.bump();
|
||||
while !p.at(EOF) && !p.at(R_CURLY) {
|
||||
match p.current() {
|
||||
L_CURLY => go(p, None),
|
||||
_ => p.bump(),
|
||||
}
|
||||
}
|
||||
p.eat(R_CURLY);
|
||||
m.complete(p, ERROR);
|
||||
}
|
||||
assert!(p.at(L_CURLY));
|
||||
let m = p.start();
|
||||
p.error(message);
|
||||
p.bump();
|
||||
expressions::expr_block_contents(p);
|
||||
p.eat(R_CURLY);
|
||||
m.complete(p, ERROR);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue