diff options
| author | Matt Peterson <ricochet1k@gmail.com> | 2017-12-30 21:47:45 -0500 |
|---|---|---|
| committer | Matt Peterson <ricochet1k@gmail.com> | 2017-12-30 21:47:45 -0500 |
| commit | 8b4bdc2f3f753e0d0b00ecc892a813e9786621e9 (patch) | |
| tree | fae8d9ab5c2d863b5b2b295f8fe90546ac56e94e /src/libsyntax/parse/parser.rs | |
| parent | f55242583cddf969c863ba8948682beb7d5bb99e (diff) | |
| download | rust-8b4bdc2f3f753e0d0b00ecc892a813e9786621e9.tar.gz rust-8b4bdc2f3f753e0d0b00ecc892a813e9786621e9.zip | |
refactor lifetime out of is_lifetime
Diffstat (limited to 'src/libsyntax/parse/parser.rs')
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 7251af77dcc..eae558f002a 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -2036,19 +2036,12 @@ impl<'a> Parser<'a> { /// Parse single lifetime 'a or panic. pub fn expect_lifetime(&mut self) -> Lifetime { - let lifetime = match self.token { - token::Lifetime(ident) => - Lifetime { ident: ident, span: self.span, id: ast::DUMMY_NODE_ID }, - token::Interpolated(ref nt) => match nt.0 { - token::NtLifetime(lifetime) => - lifetime, - _ => self.span_bug(self.span, "not a lifetime") - } - _ => self.span_bug(self.span, "not a lifetime") - }; - - self.bump(); - lifetime + if let Some(lifetime) = self.token.lifetime(self.span) { + self.bump(); + lifetime + } else { + self.span_bug(self.span, "not a lifetime") + } } /// Parse mutability (`mut` or nothing). |
