Skip to content

Commit ef9aa80

Browse files
committed
Promote most restricted keywords to strict keywords
1 parent 233e595 commit ef9aa80

File tree

8 files changed

+31
-24
lines changed

8 files changed

+31
-24
lines changed

src/libsyntax/parse/token.rs

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -411,22 +411,13 @@ fn contextual_keyword_table() -> hashmap<~str, ()> {
411411
fn restricted_keyword_table() -> hashmap<~str, ()> {
412412
let words = str_hash();
413413
let keys = ~[
414-
~"as",
415-
~"assert",
416-
~"break",
417414
~"const", ~"copy",
418-
~"do", ~"drop",
419-
~"else", ~"enum", ~"export", ~"extern",
420-
~"fail", ~"false", ~"fn", ~"for",
421-
~"if", ~"impl", ~"import",
422-
~"let", ~"log", ~"loop",
423-
~"match", ~"mod", ~"move", ~"mut",
424-
~"priv", ~"pub", ~"pure",
425-
~"ref", ~"return",
415+
~"fail", ~"fn",
416+
~"impl",
417+
~"priv", ~"pub",
418+
~"return",
426419
~"struct",
427-
~"true", ~"trait", ~"type",
428-
~"unchecked", ~"unsafe", ~"use",
429-
~"while"
420+
~"unsafe"
430421
];
431422
for keys.each |word| {
432423
words.insert(word, ());
@@ -438,6 +429,19 @@ fn restricted_keyword_table() -> hashmap<~str, ()> {
438429
fn strict_keyword_table() -> hashmap<~str, ()> {
439430
let words = str_hash();
440431
let keys = ~[
432+
~"as", ~"assert",
433+
~"break",
434+
~"do", ~"drop",
435+
~"else", ~"enum", ~"export", ~"extern",
436+
~"false", ~"for",
437+
~"if", ~"import",
438+
~"let", ~"log", ~"loop",
439+
~"match", ~"mod", ~"move", ~"mut",
440+
~"pure",
441+
~"ref",
442+
~"true", ~"trait", ~"type",
443+
~"unchecked", ~"use",
444+
~"while"
441445
];
442446
for keys.each |word| {
443447
words.insert(word, ());
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 restricted position
1+
fn false() { } //~ ERROR found `false` in ident 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 restricted position
1+
fn true() { } //~ ERROR found `true` in ident position
22
fn main() { }

src/test/compile-fail/keyword.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
mod break {
2+
//~^ ERROR found `break` in ident position
3+
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
// error-pattern:found `let` in restricted position
1+
// error-pattern:found `fail` in restricted position
22

33
fn main() {
44
match true {
5-
{let} { }
5+
{fail} { }
66
}
77
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// error-pattern:found `let` in restricted position
1+
// error-pattern:found `fail` in restricted position
22

33
fn main() {
4-
enum let = int;
4+
enum fail = int;
55
}

src/test/run-pass/module-polymorphism4.rc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ mod cat {
77
#[path = "cat.rs"]
88
mod inst;
99

10-
#[path = "trait.rs"]
11-
mod trait;
10+
#[path = "trait_.rs"]
11+
mod trait_;
1212

1313
}
1414

@@ -20,7 +20,7 @@ mod dog {
2020
#[path = "dog.rs"]
2121
mod inst;
2222

23-
#[path = "trait.rs"]
24-
mod trait;
23+
#[path = "trait_.rs"]
24+
mod trait_;
2525

2626
}

0 commit comments

Comments
 (0)