]> git.lizzy.rs Git - rust.git/commitdiff
parser: {check,expect}_lifetime into ty.rs
authorMazdak Farrokhzad <twingoow@gmail.com>
Sun, 11 Aug 2019 18:46:34 +0000 (20:46 +0200)
committerMazdak Farrokhzad <twingoow@gmail.com>
Sun, 11 Aug 2019 18:46:34 +0000 (20:46 +0200)
src/libsyntax/parse/parser.rs
src/libsyntax/parse/parser/ty.rs

index afa475a4c8bf0ca08fdbdb3d3023a29f1784d7d7..1c1428c5713f70b146192b66c97fe6efdde67d23 100644 (file)
@@ -11,7 +11,7 @@
 mod generics;
 
 use crate::ast::{self, AttrStyle, Attribute, Arg, BindingMode, StrStyle, SelfKind};
-use crate::ast::{FnDecl, Ident, IsAsync, Lifetime, MacDelimiter, Mutability, TyKind};
+use crate::ast::{FnDecl, Ident, IsAsync, MacDelimiter, Mutability, TyKind};
 use crate::ast::{Visibility, VisibilityKind, Unsafety, CrateSugar};
 use crate::ext::hygiene::SyntaxContext;
 use crate::source_map::{self, respan};
@@ -1046,22 +1046,6 @@ fn parse_arg_general<F>(
         Ok(Arg { attrs: attrs.into(), id: ast::DUMMY_NODE_ID, pat, span, ty })
     }
 
-    crate fn check_lifetime(&mut self) -> bool {
-        self.expected_tokens.push(TokenType::Lifetime);
-        self.token.is_lifetime()
-    }
-
-    /// Parses a single lifetime `'a` or panics.
-    crate fn expect_lifetime(&mut self) -> Lifetime {
-        if let Some(ident) = self.token.lifetime() {
-            let span = self.token.span;
-            self.bump();
-            Lifetime { ident: Ident::new(ident.name, span), id: ast::DUMMY_NODE_ID }
-        } else {
-            self.span_bug(self.token.span, "not a lifetime")
-        }
-    }
-
     /// Parses mutability (`mut` or nothing).
     fn parse_mutability(&mut self) -> Mutability {
         if self.eat_keyword(kw::Mut) {
index e01ce9a48c0dd887041541c6ce6e34a07a71dc9c..1eb3d441e698a06fd7d1748ac5d1c5439defa5b1 100644 (file)
@@ -1,8 +1,8 @@
-use super::{Parser, PResult, PathStyle, PrevTokenKind};
+use super::{Parser, PResult, PathStyle, PrevTokenKind, TokenType};
 
 use crate::{maybe_whole, maybe_recover_from_interpolated_ty_qpath};
 use crate::ptr::P;
-use crate::ast::{self, Ty, TyKind, MutTy, BareFnTy, FunctionRetTy, GenericParam};
+use crate::ast::{self, Ty, TyKind, MutTy, BareFnTy, FunctionRetTy, GenericParam, Lifetime, Ident};
 use crate::ast::{TraitBoundModifier, TraitObjectSyntax, GenericBound, GenericBounds, PolyTraitRef};
 use crate::ast::{Mutability, AnonConst, FnDecl, Mac_};
 use crate::parse::token::{self, Token};
@@ -442,4 +442,20 @@ pub(super) fn parse_late_bound_lifetime_defs(&mut self) -> PResult<'a, Vec<Gener
             Ok(Vec::new())
         }
     }
+
+    crate fn check_lifetime(&mut self) -> bool {
+        self.expected_tokens.push(TokenType::Lifetime);
+        self.token.is_lifetime()
+    }
+
+    /// Parses a single lifetime `'a` or panics.
+    crate fn expect_lifetime(&mut self) -> Lifetime {
+        if let Some(ident) = self.token.lifetime() {
+            let span = self.token.span;
+            self.bump();
+            Lifetime { ident: Ident::new(ident.name, span), id: ast::DUMMY_NODE_ID }
+        } else {
+            self.span_bug(self.token.span, "not a lifetime")
+        }
+    }
 }