Skip to content

Commit d477160

Browse files
committed
---
yaml --- r: 15678 b: refs/heads/try c: 5eca3c2 h: refs/heads/master v: v3
1 parent 33bcf08 commit d477160

File tree

7 files changed

+18
-15
lines changed

7 files changed

+18
-15
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: 21dc41649bc48cea25dd498c3e11d6f9c50f0aee
5+
refs/heads/try: 5eca3c2210964e8987fea250224544b22a6f6520
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,18 @@ fn check_restricted_keywords(p: parser) {
9595
alt p.token {
9696
token::IDENT(_, false) {
9797
let w = token_to_str(p.reader, p.token);
98-
if is_restricted_keyword(p, w) {
99-
p.fatal("found `" + w + "` in expression position");
100-
}
98+
check_restricted_keywords_(p, w);
10199
}
102100
_ { }
103101
}
104102
}
105103

104+
fn check_restricted_keywords_(p: parser, w: ast::ident) {
105+
if is_restricted_keyword(p, w) {
106+
p.fatal("found `" + w + "` in restricted position");
107+
}
108+
}
109+
106110
fn expect_gt(p: parser) {
107111
if p.token == token::GT {
108112
p.bump();

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

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1384,7 +1384,11 @@ fn parse_pat(p: parser) -> @ast::pat {
13841384
}
13851385

13861386
let lo1 = p.last_span.lo;
1387-
let fieldname = parse_ident(p);
1387+
let fieldname = if p.look_ahead(1u) == token::COLON {
1388+
parse_ident(p)
1389+
} else {
1390+
parse_value_ident(p)
1391+
};
13881392
let hi1 = p.last_span.lo;
13891393
let fieldpath = ast_util::ident_to_path(mk_sp(lo1, hi1),
13901394
fieldname);
@@ -1393,9 +1397,6 @@ fn parse_pat(p: parser) -> @ast::pat {
13931397
p.bump();
13941398
subpat = parse_pat(p);
13951399
} else {
1396-
if is_restricted_keyword(p, fieldname) {
1397-
p.fatal("found `" + fieldname + "` in binding position");
1398-
}
13991400
subpat = @{id: p.get_id(),
14001401
node: ast::pat_ident(fieldpath, none),
14011402
span: mk_sp(lo, hi)};
@@ -2147,9 +2148,7 @@ fn parse_item_enum(p: parser, attrs: [ast::attribute]) -> @ast::item {
21472148
let mut variants: [ast::variant] = [];
21482149
// Newtype syntax
21492150
if p.token == token::EQ {
2150-
if is_restricted_keyword(p, id) {
2151-
p.fatal("found `" + id + "` in enum constructor position");
2152-
}
2151+
check_restricted_keywords_(p, id);
21532152
p.bump();
21542153
let ty = parse_ty(p, false);
21552154
expect(p, token::SEMI);
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
fn false() { } //! ERROR found `false` in expression position
1+
fn false() { } //! ERROR found `false` in restricted position
22
fn main() { }
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
fn true() { } //! ERROR found `true` in expression position
1+
fn true() { } //! ERROR found `true` in restricted position
22
fn main() { }

branches/try/src/test/compile-fail/restricted-keyword1.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// error-pattern:found `let` in binding position
1+
// error-pattern:found `let` in restricted position
22

33
fn main() {
44
alt true {

branches/try/src/test/compile-fail/restricted-keyword2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// error-pattern:found `let` in enum constructor position
1+
// error-pattern:found `let` in restricted position
22

33
fn main() {
44
enum let = int;

0 commit comments

Comments
 (0)