Skip to content

Commit 78c5350

Browse files
committed
---
yaml --- r: 15636 b: refs/heads/try c: 98ac8d4 h: refs/heads/master v: v3
1 parent 0c6e962 commit 78c5350

File tree

4 files changed

+18
-21
lines changed

4 files changed

+18
-21
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
refs/heads/master: 61b1875c16de39c166b0f4d54bba19f9c6777d1a
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
5-
refs/heads/try: 7ee90cc7be7b74fd8e63ef79a19844343ad1dd9c
5+
refs/heads/try: 98ac8d46251cbe8807e5db54e8f0c2f23b7288d5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

branches/try/src/librustsyntax/parse/common.rs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ fn parse_path_list_ident(p: parser) -> ast::path_list_ident {
4343
}
4444

4545
fn parse_value_ident(p: parser) -> ast::ident {
46-
check_bad_word(p);
46+
check_bad_expr_word(p);
4747
ret parse_ident(p);
4848
}
4949

@@ -87,11 +87,19 @@ fn expect_keyword(p: parser, word: str) {
8787
}
8888
}
8989

90-
fn check_bad_word(p: parser) {
91-
if token::is_bad_expr_word(p.token, p.bad_expr_words,
92-
*p.reader.interner) {
90+
fn is_bad_expr_word(p: parser, word: str) -> bool {
91+
p.bad_expr_words.contains_key(word)
92+
}
93+
94+
fn check_bad_expr_word(p: parser) {
95+
alt p.token {
96+
token::IDENT(_, false) {
9397
let w = token_to_str(p.reader, p.token);
94-
p.fatal("found " + w + " in expression position");
98+
if is_bad_expr_word(p, w) {
99+
p.fatal("found `" + w + "` in expression position");
100+
}
101+
}
102+
_ { }
95103
}
96104
}
97105

branches/try/src/librustsyntax/parse/parser.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ fn parse_path(p: parser) -> @ast::path {
543543
fn parse_value_path(p: parser) -> @ast::path {
544544
let pt = parse_path(p);
545545
let last_word = vec::last(pt.idents);
546-
if p.bad_expr_words.contains_key(last_word) {
546+
if is_bad_expr_word(p, last_word) {
547547
p.fatal("found " + last_word + " in expression position");
548548
}
549549
pt
@@ -802,7 +802,7 @@ fn parse_bottom_expr(p: parser) -> pexpr {
802802
} else if p.token == token::MOD_SEP ||
803803
is_ident(p.token) && !is_keyword(p, "true") &&
804804
!is_keyword(p, "false") {
805-
check_bad_word(p);
805+
check_bad_expr_word(p);
806806
let pth = parse_path_and_ty_param_substs(p, true);
807807
hi = pth.span.hi;
808808
ex = ast::expr_path(pth);
@@ -1370,7 +1370,7 @@ fn parse_pat(p: parser) -> @ast::pat {
13701370
p.bump();
13711371
subpat = parse_pat(p);
13721372
} else {
1373-
if p.bad_expr_words.contains_key(fieldname) {
1373+
if is_bad_expr_word(p, fieldname) {
13741374
p.fatal("found " + fieldname + " in binding position");
13751375
}
13761376
subpat = @{id: p.get_id(),
@@ -2098,7 +2098,7 @@ fn parse_item_enum(p: parser, attrs: [ast::attribute]) -> @ast::item {
20982098
let mut variants: [ast::variant] = [];
20992099
// Newtype syntax
21002100
if p.token == token::EQ {
2101-
if p.bad_expr_words.contains_key(id) {
2101+
if is_bad_expr_word(p, id) {
21022102
p.fatal("found " + id + " in enum constructor position");
21032103
}
21042104
p.bump();

branches/try/src/librustsyntax/parse/token.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -200,17 +200,6 @@ fn is_bar(t: token::token) -> bool {
200200
alt t { token::BINOP(token::OR) | token::OROR { true } _ { false } }
201201
}
202202

203-
fn is_bad_expr_word(t: token,
204-
bad_expr_words: hashmap<str, ()>,
205-
in: interner<str>) -> bool {
206-
alt t {
207-
token::IDENT(_, false) {
208-
bad_expr_words.contains_key(to_str(in, t))
209-
}
210-
_ { false }
211-
}
212-
}
213-
214203
#[doc = "
215204
All the valid words that have meaning in the Rust language. Some of these are
216205
nonetheless valid as identifiers becasue they are unambiguous.

0 commit comments

Comments
 (0)