diff options
| author | Erik Price <erik.price16@gmail.com> | 2013-12-09 23:16:18 -0800 |
|---|---|---|
| committer | Erik Price <erik.price16@gmail.com> | 2013-12-11 10:54:06 -0800 |
| commit | 5731ca3078318a66a13208133d8839a9f9f92629 (patch) | |
| tree | 322fdafcb432387c0c8131dbd22d57ecc38144b5 /src/libsyntax/parse | |
| parent | d441c5468814b0d8f9ccdba426baf1f16b5134fc (diff) | |
| download | rust-5731ca3078318a66a13208133d8839a9f9f92629.tar.gz rust-5731ca3078318a66a13208133d8839a9f9f92629.zip | |
Make 'self lifetime illegal.
Also remove all instances of 'self within the codebase. This fixes #10889.
Diffstat (limited to 'src/libsyntax/parse')
| -rw-r--r-- | src/libsyntax/parse/lexer.rs | 13 | ||||
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 6 |
2 files changed, 10 insertions, 9 deletions
diff --git a/src/libsyntax/parse/lexer.rs b/src/libsyntax/parse/lexer.rs index 22a999ab744..d48c1d9d8d7 100644 --- a/src/libsyntax/parse/lexer.rs +++ b/src/libsyntax/parse/lexer.rs @@ -764,14 +764,15 @@ fn next_token_inner(rdr: @mut StringReader) -> token::Token { 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) { + if token::is_keyword(token::keywords::Self, tok) { fatal_span(rdr, start, rdr.last_pos, - ~"invalid lifetime name"); + ~"invalid lifetime name: 'self is no longer a special lifetime"); + } else if token::is_any_keyword(tok) && + !token::is_keyword(token::keywords::Static, tok) { + fatal_span(rdr, start, rdr.last_pos, ~"invalid lifetime name"); + } else { + token::LIFETIME(ident) } - - token::LIFETIME(ident) }) } diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 4270a4d0dc5..aa37d859d79 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -102,13 +102,13 @@ pub enum PathParsingMode { /// A path with no type parameters; e.g. `foo::bar::Baz` NoTypesAllowed, /// A path with a lifetime and type parameters, with no double colons - /// before the type parameters; e.g. `foo::bar<'self>::Baz<T>` + /// before the type parameters; e.g. `foo::bar<'a>::Baz<T>` LifetimeAndTypesWithoutColons, /// A path with a lifetime and type parameters with double colons before - /// the type parameters; e.g. `foo::bar::<'self>::Baz::<T>` + /// the type parameters; e.g. `foo::bar::<'a>::Baz::<T>` LifetimeAndTypesWithColons, /// A path with a lifetime and type parameters with bounds before the last - /// set of type parameters only; e.g. `foo::bar<'self>::Baz:X+Y<T>` This + /// set of type parameters only; e.g. `foo::bar<'a>::Baz:X+Y<T>` This /// form does not use extra double colons. LifetimeAndTypesAndBounds, } |
