1
Fork 0

syntax: Clean up the bad_expr_word functions

This commit is contained in:
Brian Anderson 2012-04-24 21:05:25 -07:00
parent 7ee90cc7be
commit 98ac8d4625
3 changed files with 17 additions and 20 deletions

View file

@ -543,7 +543,7 @@ fn parse_path(p: parser) -> @ast::path {
fn parse_value_path(p: parser) -> @ast::path {
let pt = parse_path(p);
let last_word = vec::last(pt.idents);
if p.bad_expr_words.contains_key(last_word) {
if is_bad_expr_word(p, last_word) {
p.fatal("found " + last_word + " in expression position");
}
pt
@ -802,7 +802,7 @@ fn parse_bottom_expr(p: parser) -> pexpr {
} else if p.token == token::MOD_SEP ||
is_ident(p.token) && !is_keyword(p, "true") &&
!is_keyword(p, "false") {
check_bad_word(p);
check_bad_expr_word(p);
let pth = parse_path_and_ty_param_substs(p, true);
hi = pth.span.hi;
ex = ast::expr_path(pth);
@ -1370,7 +1370,7 @@ fn parse_pat(p: parser) -> @ast::pat {
p.bump();
subpat = parse_pat(p);
} else {
if p.bad_expr_words.contains_key(fieldname) {
if is_bad_expr_word(p, fieldname) {
p.fatal("found " + fieldname + " in binding position");
}
subpat = @{id: p.get_id(),
@ -2098,7 +2098,7 @@ fn parse_item_enum(p: parser, attrs: [ast::attribute]) -> @ast::item {
let mut variants: [ast::variant] = [];
// Newtype syntax
if p.token == token::EQ {
if p.bad_expr_words.contains_key(id) {
if is_bad_expr_word(p, id) {
p.fatal("found " + id + " in enum constructor position");
}
p.bump();