about summary refs log tree commit diff
path: root/src/libsyntax/parse
diff options
context:
space:
mode:
authorLéo Testard <leo.testard@gmail.com>2013-11-26 16:35:12 +0100
committerLéo Testard <leo.testard@gmail.com>2013-12-05 21:06:00 +0100
commit74757af096e4418d410b3099622ddcdb13e87568 (patch)
treeeb5e062069c2d6331cdce21502f3179e6a0979a8 /src/libsyntax/parse
parent617ce856db7e8088b07f6820a331e25f1f5a921a (diff)
downloadrust-74757af096e4418d410b3099622ddcdb13e87568.tar.gz
rust-74757af096e4418d410b3099622ddcdb13e87568.zip
Forbid keywords as lifetime parameters names.
Diffstat (limited to 'src/libsyntax/parse')
-rw-r--r--src/libsyntax/parse/lexer.rs12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/libsyntax/parse/lexer.rs b/src/libsyntax/parse/lexer.rs
index fa93c5f8977..9c35bb838a3 100644
--- a/src/libsyntax/parse/lexer.rs
+++ b/src/libsyntax/parse/lexer.rs
@@ -774,7 +774,17 @@ fn next_token_inner(rdr: @mut StringReader) -> token::Token {
                 bump(rdr);
             }
             return with_str_from(rdr, start, |lifetime_name| {
-                token::LIFETIME(str_to_ident(lifetime_name))
+                let ident = str_to_ident(lifetime_name);
+                let tok = &token::IDENT(ident, false);
+
+                if token::is_any_keyword(tok)
+                    && !token::is_keyword(token::keywords::Static, tok)
+                    && !token::is_keyword(token::keywords::Self, tok) {
+                    fatal_span(rdr, start, rdr.last_pos,
+                        ~"invalid lifetime name");
+                }
+
+                token::LIFETIME(ident)
             })
         }