]> git.lizzy.rs Git - rust.git/blobdiff - src/libsyntax/ast.rs
parse extern consts
[rust.git] / src / libsyntax / ast.rs
index ca39fbd6c5d0f83b91a2ad10d760b0b9fad6cbd1..5041d43b16c087c878dd19c3b0906b74166d8964 100644 (file)
@@ -2605,6 +2605,9 @@ pub fn generics(&self) -> Option<&Generics> {
 /// An item within an `extern` block.
 #[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
 pub enum ForeignItemKind {
+    /// A constant, `const $ident: $ty $def?;` where `def ::= "=" $expr? ;`.
+    /// If `def` is parsed, then the constant is provided, and otherwise required.
+    Const(P<Ty>, Option<P<Expr>>),
     /// A static item (`static FOO: u8`).
     Static(P<Ty>, Mutability, Option<P<Expr>>),
     /// A function.
@@ -2619,6 +2622,7 @@ impl ForeignItemKind {
     pub fn descriptive_variant(&self) -> &str {
         match *self {
             ForeignItemKind::Fn(..) => "foreign function",
+            ForeignItemKind::Const(..) => "foreign const item",
             ForeignItemKind::Static(..) => "foreign static item",
             ForeignItemKind::TyAlias(..) => "foreign type",
             ForeignItemKind::Macro(..) => "macro in foreign module",