summary refs log tree commit diff
path: root/src/libsyntax/parse/parser.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/libsyntax/parse/parser.rs')
-rw-r--r--src/libsyntax/parse/parser.rs19
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).