Skip to content

Commit 08d0707

Browse files
committed
syntax: Make 'true' and 'false' bad words
When these are idents they are always shadowed by the boolean constants.
1 parent 98ac8d4 commit 08d0707

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

src/librustsyntax/parse/token.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,6 @@ fn keyword_table() -> hashmap<str, ()> {
213213
"as",
214214
"bind",
215215
"else",
216-
"false",
217216
"implements",
218217
"move",
219218
"of",
@@ -222,7 +221,6 @@ fn keyword_table() -> hashmap<str, ()> {
222221
"send",
223222
"static",
224223
"to",
225-
"true",
226224
"use",
227225
"with"
228226
];
@@ -241,9 +239,9 @@ fn bad_expr_word_table() -> hashmap<str, ()> {
241239
let words = str_hash();
242240
let keys = ["alt", "assert", "be", "break", "check", "claim",
243241
"class", "const", "cont", "copy", "crust", "do", "else",
244-
"enum", "export", "fail", "fn", "for", "if", "iface",
245-
"impl", "import", "let", "log", "loop", "mod",
246-
"mut", "native", "new", "pure", "resource",
242+
"enum", "export", "fail", "false", "fn", "for", "if",
243+
"iface", "impl", "import", "let", "log", "loop", "mod",
244+
"mut", "native", "new", "pure", "resource", "true",
247245
"ret", "trait", "type", "unchecked", "unsafe", "while"];
248246
for keys.each {|word|
249247
words.insert(word, ());
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
fn false() { } //! ERROR found `false` in expression position
2+
fn main() { }
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
fn true() { } //! ERROR found `true` in expression position
2+
fn main() { }

0 commit comments

Comments
 (0)