Fix some parser bugs

This commit is contained in:
Aleksey Kladov 2018-08-13 18:23:14 +03:00
parent d1eceefeb8
commit 9149fd2c0c
9 changed files with 213 additions and 15 deletions

View file

@ -62,7 +62,7 @@ fn path_segment(p: &mut Parser, mode: Mode, first: bool) {
}
SELF_KW | SUPER_KW => p.bump(),
_ => {
p.error("expected identifier");
p.err_and_bump("expected identifier");
}
};
segment.complete(p, PATH_SEGMENT);

View file

@ -60,6 +60,7 @@ fn atom_pat(p: &mut Parser) -> Option<CompletedMarker> {
// let Bar(..) = ();
// }
fn path_pat(p: &mut Parser) -> CompletedMarker {
assert!(paths::is_path_start(p));
let m = p.start();
paths::expr_path(p);
let kind = match p.current() {
@ -116,8 +117,11 @@ fn struct_pat_fields(p: &mut Parser) {
p.bump();
pattern(p);
}
_ => {
REF_KW | MUT_KW | IDENT => {
bind_pat(p, false);
},
_ => {
p.err_and_bump("expected ident");
}
}
if !p.at(R_CURLY) {

View file

@ -121,7 +121,12 @@ fn where_predicate(p: &mut Parser) {
lifetime_bounds(p)
} else {
types::path_type(p);
bounds(p);
if p.at(COLON) {
bounds(p);
} else {
p.error("expected colon")
}
}
m.complete(p, WHERE_PRED);
}

View file

@ -166,8 +166,11 @@ fn fn_pointer_type(p: &mut Parser) {
p.error("expected `fn`");
return;
}
params::param_list_opt_patterns(p);
if p.at(L_PAREN) {
params::param_list_opt_patterns(p);
} else {
p.error("expected parameters")
}
// test fn_pointer_type_with_ret
// type F = fn() -> ();
fn_ret_type(p);