Skip to content

Commit bde5a84

Browse files
committed
parser: Make parse_value_path use parse_value_ident
1 parent 8ab9efe commit bde5a84

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/librustsyntax/parse/parser.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,13 @@ fn parse_lit(p: parser) -> ast::lit {
508508
}
509509

510510
fn parse_path_without_tps(p: parser) -> @ast::path {
511+
parse_path_without_tps_(p, parse_ident, parse_ident)
512+
}
513+
514+
fn parse_path_without_tps_(
515+
p: parser, parse_ident: fn(parser) -> ast::ident,
516+
parse_last_ident: fn(parser) -> ast::ident) -> @ast::path {
517+
511518
let lo = p.span.lo;
512519
let global = eat(p, token::MOD_SEP);
513520
let mut ids = [];
@@ -516,10 +523,11 @@ fn parse_path_without_tps(p: parser) -> @ast::path {
516523
p.look_ahead(2u) != token::LT
517524
&& p.look_ahead(1u) == token::MOD_SEP;
518525

519-
ids += [parse_ident(p)];
520526
if is_not_last {
527+
ids += [parse_ident(p)];
521528
expect(p, token::MOD_SEP);
522529
} else {
530+
ids += [parse_last_ident(p)];
523531
break;
524532
}
525533
}
@@ -528,12 +536,7 @@ fn parse_path_without_tps(p: parser) -> @ast::path {
528536
}
529537

530538
fn parse_value_path(p: parser) -> @ast::path {
531-
let pt = parse_path_without_tps(p);
532-
let last_word = vec::last(pt.idents);
533-
if is_restricted_keyword(p, last_word) {
534-
p.fatal("found " + last_word + " in expression position");
535-
}
536-
pt
539+
parse_path_without_tps_(p, parse_ident, parse_value_ident)
537540
}
538541

539542
fn parse_path_with_tps(p: parser, colons: bool) -> @ast::path {

0 commit comments

Comments
 (0)