about summary refs log tree commit diff
path: root/src/libsyntax/parse/token.rs
diff options
context:
space:
mode:
authorvarkor <github@varkor.com>2019-02-05 16:49:38 +0100
committervarkor <github@varkor.com>2019-02-07 15:02:16 +0100
commit0a8d98a270da057975d3cc552a4bb5f0bda5a3af (patch)
treed8fb828a74b91a124f4a08bb4522ba1e9274ec60 /src/libsyntax/parse/token.rs
parent8d83521f0b1c842e42f87dd59dbca9c98b456cbd (diff)
downloadrust-0a8d98a270da057975d3cc552a4bb5f0bda5a3af.tar.gz
rust-0a8d98a270da057975d3cc552a4bb5f0bda5a3af.zip
Parse const generics
Co-Authored-By: Gabriel Smith <yodaldevoid@users.noreply.github.com>
Diffstat (limited to 'src/libsyntax/parse/token.rs')
-rw-r--r--src/libsyntax/parse/token.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs
index 3b1fa5ea01f..dad32072739 100644
--- a/src/libsyntax/parse/token.rs
+++ b/src/libsyntax/parse/token.rs
@@ -279,6 +279,20 @@ impl Token {
         }
     }
 
+    /// Returns `true` if the token can appear at the start of a const param.
+    pub fn can_begin_const_arg(&self) -> bool {
+        match self {
+            OpenDelim(Brace) => true,
+            Interpolated(ref nt) => match nt.0 {
+                NtExpr(..) => true,
+                NtBlock(..) => true,
+                NtLiteral(..) => true,
+                _ => false,
+            }
+            _ => self.can_begin_literal_or_bool(),
+        }
+    }
+
     /// Returns `true` if the token can appear at the start of a generic bound.
     crate fn can_begin_bound(&self) -> bool {
         self.is_path_start() || self.is_lifetime() || self.is_keyword(keywords::For) ||