]> git.lizzy.rs Git - rust.git/commitdiff
update :vis implementation to current rust
authorAlex Burka <alex@alexburka.com>
Sun, 2 Apr 2017 04:21:12 +0000 (04:21 +0000)
committerAlex Burka <alex@alexburka.com>
Sat, 15 Apr 2017 19:06:19 +0000 (19:06 +0000)
src/libsyntax/ext/tt/macro_rules.rs
src/libsyntax/parse/parser.rs
src/test/run-pass/macro-pub-matcher.rs

index 4e197a85ebd9629192c6165ec5b4a4acf89ace63..f888e29bdabb491deaf2b1ad966cc3db9d9748ec 100644 (file)
@@ -793,13 +793,13 @@ fn is_in_follow(tok: &quoted::TokenTree, frag: &str) -> Result<bool, (String, &'
             "vis" => {
                 // Explicitly disallow `priv`, on the off chance it comes back.
                 match *tok {
-                    Comma => Ok(true),
-                    ModSep => Ok(true),
-                    MatchNt(_, ref frag, _, _) => {
-                        let name = frag.name.as_str();
-                        Ok(name == "ident" || name == "ty")
+                    TokenTree::Token(_, ref tok) => match *tok {
+                        Comma => Ok(true),
+                        ModSep => Ok(true),
+                        Ident(i) if i.name != "priv" => Ok(true),
+                        _ => Ok(false)
                     },
-                    Ident(i, _) if i.name.as_str() != "priv" => Ok(true),
+                    TokenTree::MetaVarDecl(_, _, frag) if frag.name =="ident" || frag.name == "ty" => Ok(true),
                     _ => Ok(false)
                 }
             },
index 3b928ea93c78aef2fe8bdfff94f208bcd3d0b1d0..11becd58293baabff7e39da1c93eea2b44af800b 100644 (file)
@@ -5056,7 +5056,7 @@ fn parse_struct_decl_field(&mut self) -> PResult<'a, StructField> {
     /// and `pub(super)` for `pub(in super)`.  If the following element can't be a tuple (i.e. it's
     /// a function definition, it's not a tuple struct field) and the contents within the parens
     /// isn't valid, emit a proper diagnostic.
-    fn parse_visibility(&mut self, can_take_tuple: bool) -> PResult<'a, Visibility> {
+    pub fn parse_visibility(&mut self, can_take_tuple: bool) -> PResult<'a, Visibility> {
         if !self.eat_keyword(keywords::Pub) {
             return Ok(Visibility::Inherited)
         }
index 64fa0bef464cc796a5a5c99000e5f15a559c5194..7de9cc6bf21d7a96030d05e2ccbca5e865543ff3 100644 (file)
@@ -1,5 +1,4 @@
 #![allow(dead_code, unused_imports)]
-#![feature(pub_restricted)]
 
 /**
 Ensure that `:vis` matches can be captured in existing positions, and passed
@@ -56,15 +55,15 @@ mod with_pub_restricted {
 
 mod garden {
     mod with_pub_restricted_path {
-        vis_passthru! { pub(::garden) const A: i32 = 0; }
-        vis_passthru! { pub(::garden) enum B {} }
-        vis_passthru! { pub(::garden) extern "C" fn c() {} }
-        vis_passthru! { pub(::garden) mod d {} }
-        vis_passthru! { pub(::garden) static E: i32 = 0; }
-        vis_passthru! { pub(::garden) struct F; }
-        vis_passthru! { pub(::garden) trait G {} }
-        vis_passthru! { pub(::garden) type H = i32; }
-        vis_passthru! { pub(::garden) use A as I; }
+        vis_passthru! { pub(in garden) const A: i32 = 0; }
+        vis_passthru! { pub(in garden) enum B {} }
+        vis_passthru! { pub(in garden) extern "C" fn c() {} }
+        vis_passthru! { pub(in garden) mod d {} }
+        vis_passthru! { pub(in garden) static E: i32 = 0; }
+        vis_passthru! { pub(in garden) struct F; }
+        vis_passthru! { pub(in garden) trait G {} }
+        vis_passthru! { pub(in garden) type H = i32; }
+        vis_passthru! { pub(in garden) use A as I; }
     }
 }