Promote most restricted keywords to strict keywords
This commit is contained in:
parent
233e595b61
commit
ef9aa80438
8 changed files with 31 additions and 24 deletions
|
@ -411,22 +411,13 @@ fn contextual_keyword_table() -> hashmap<~str, ()> {
|
||||||
fn restricted_keyword_table() -> hashmap<~str, ()> {
|
fn restricted_keyword_table() -> hashmap<~str, ()> {
|
||||||
let words = str_hash();
|
let words = str_hash();
|
||||||
let keys = ~[
|
let keys = ~[
|
||||||
~"as",
|
|
||||||
~"assert",
|
|
||||||
~"break",
|
|
||||||
~"const", ~"copy",
|
~"const", ~"copy",
|
||||||
~"do", ~"drop",
|
~"fail", ~"fn",
|
||||||
~"else", ~"enum", ~"export", ~"extern",
|
~"impl",
|
||||||
~"fail", ~"false", ~"fn", ~"for",
|
~"priv", ~"pub",
|
||||||
~"if", ~"impl", ~"import",
|
~"return",
|
||||||
~"let", ~"log", ~"loop",
|
|
||||||
~"match", ~"mod", ~"move", ~"mut",
|
|
||||||
~"priv", ~"pub", ~"pure",
|
|
||||||
~"ref", ~"return",
|
|
||||||
~"struct",
|
~"struct",
|
||||||
~"true", ~"trait", ~"type",
|
~"unsafe"
|
||||||
~"unchecked", ~"unsafe", ~"use",
|
|
||||||
~"while"
|
|
||||||
];
|
];
|
||||||
for keys.each |word| {
|
for keys.each |word| {
|
||||||
words.insert(word, ());
|
words.insert(word, ());
|
||||||
|
@ -438,6 +429,19 @@ fn restricted_keyword_table() -> hashmap<~str, ()> {
|
||||||
fn strict_keyword_table() -> hashmap<~str, ()> {
|
fn strict_keyword_table() -> hashmap<~str, ()> {
|
||||||
let words = str_hash();
|
let words = str_hash();
|
||||||
let keys = ~[
|
let keys = ~[
|
||||||
|
~"as", ~"assert",
|
||||||
|
~"break",
|
||||||
|
~"do", ~"drop",
|
||||||
|
~"else", ~"enum", ~"export", ~"extern",
|
||||||
|
~"false", ~"for",
|
||||||
|
~"if", ~"import",
|
||||||
|
~"let", ~"log", ~"loop",
|
||||||
|
~"match", ~"mod", ~"move", ~"mut",
|
||||||
|
~"pure",
|
||||||
|
~"ref",
|
||||||
|
~"true", ~"trait", ~"type",
|
||||||
|
~"unchecked", ~"use",
|
||||||
|
~"while"
|
||||||
];
|
];
|
||||||
for keys.each |word| {
|
for keys.each |word| {
|
||||||
words.insert(word, ());
|
words.insert(word, ());
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
fn false() { } //~ ERROR found `false` in restricted position
|
fn false() { } //~ ERROR found `false` in ident position
|
||||||
fn main() { }
|
fn main() { }
|
|
@ -1,2 +1,2 @@
|
||||||
fn true() { } //~ ERROR found `true` in restricted position
|
fn true() { } //~ ERROR found `true` in ident position
|
||||||
fn main() { }
|
fn main() { }
|
3
src/test/compile-fail/keyword.rs
Normal file
3
src/test/compile-fail/keyword.rs
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
mod break {
|
||||||
|
//~^ ERROR found `break` in ident position
|
||||||
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
// error-pattern:found `let` in restricted position
|
// error-pattern:found `fail` in restricted position
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
match true {
|
match true {
|
||||||
{let} { }
|
{fail} { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// error-pattern:found `let` in restricted position
|
// error-pattern:found `fail` in restricted position
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
enum let = int;
|
enum fail = int;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,8 +7,8 @@ mod cat {
|
||||||
#[path = "cat.rs"]
|
#[path = "cat.rs"]
|
||||||
mod inst;
|
mod inst;
|
||||||
|
|
||||||
#[path = "trait.rs"]
|
#[path = "trait_.rs"]
|
||||||
mod trait;
|
mod trait_;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ mod dog {
|
||||||
#[path = "dog.rs"]
|
#[path = "dog.rs"]
|
||||||
mod inst;
|
mod inst;
|
||||||
|
|
||||||
#[path = "trait.rs"]
|
#[path = "trait_.rs"]
|
||||||
mod trait;
|
mod trait_;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue