about summary refs log tree commit diff
path: root/src/libsyntax/parse/parser.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2014-11-18 23:51:43 +0000
committerbors <bors@rust-lang.org>2014-11-18 23:51:43 +0000
commite09d98603e608c9e47d4c89f7b4dca87a4b56da3 (patch)
tree830bdec7e6fc4c19726398108bbf760a64ba0131 /src/libsyntax/parse/parser.rs
parent1628b98183bfec13e9407a905324dda047c3a550 (diff)
parent2293a04b4936a11fc3e09f3df8a8ab591e034f29 (diff)
downloadrust-e09d98603e608c9e47d4c89f7b4dca87a4b56da3.tar.gz
rust-e09d98603e608c9e47d4c89f7b4dca87a4b56da3.zip
auto merge of #19044 : murarth/rust/libsyntax-view-item, r=alexcrichton
Allows parsing view items (`use` and `extern crate`) individually. Does not change behavior of any existing functions.

Closes #19024
Diffstat (limited to 'src/libsyntax/parse/parser.rs')
-rw-r--r--src/libsyntax/parse/parser.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index 40c4ac9f8c0..50b1a2204b0 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -5620,6 +5620,14 @@ impl<'a> Parser<'a> {
         }
     }
 
+    /// Parse a ViewItem, e.g. `use foo::bar` or `extern crate foo`
+    pub fn parse_view_item(&mut self, attrs: Vec<Attribute>) -> ViewItem {
+        match self.parse_item_or_view_item(attrs, false) {
+            IoviViewItem(vi) => vi,
+            _ => self.fatal("expected `use` or `extern crate`"),
+        }
+    }
+
     /// Parse, e.g., "use a::b::{z,y}"
     fn parse_use(&mut self) -> ViewItem_ {
         return ViewItemUse(self.parse_view_path());