]> git.lizzy.rs Git - rust.git/commitdiff
parse interpolated visibility tokens
authorAlex Burka <alex@alexburka.com>
Sun, 2 Apr 2017 04:46:51 +0000 (04:46 +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 f888e29bdabb491deaf2b1ad966cc3db9d9748ec..84c909284a8fac116e002276a9c503de37919547 100644 (file)
@@ -799,7 +799,8 @@ fn is_in_follow(tok: &quoted::TokenTree, frag: &str) -> Result<bool, (String, &'
                         Ident(i) if i.name != "priv" => Ok(true),
                         _ => Ok(false)
                     },
-                    TokenTree::MetaVarDecl(_, _, frag) if frag.name =="ident" || frag.name == "ty" => Ok(true),
+                    TokenTree::MetaVarDecl(_, _, frag)
+                        if frag.name =="ident" || frag.name == "ty" => Ok(true),
                     _ => Ok(false)
                 }
             },
index 11becd58293baabff7e39da1c93eea2b44af800b..31669e1bbe3a7d3ea83e07e78f0350bf601f3c03 100644 (file)
@@ -5057,6 +5057,8 @@ fn parse_struct_decl_field(&mut self) -> PResult<'a, StructField> {
     /// a function definition, it's not a tuple struct field) and the contents within the parens
     /// isn't valid, emit a proper diagnostic.
     pub fn parse_visibility(&mut self, can_take_tuple: bool) -> PResult<'a, Visibility> {
+        maybe_whole!(self, NtVis, |x| x);
+
         if !self.eat_keyword(keywords::Pub) {
             return Ok(Visibility::Inherited)
         }
index 7de9cc6bf21d7a96030d05e2ccbca5e865543ff3..d5b25e6cdf2d367c875fe661b6458a79e91c245f 100644 (file)
@@ -1,3 +1,13 @@
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
 #![allow(dead_code, unused_imports)]
 
 /**
@@ -96,11 +106,13 @@ macro_rules! vis_parse_struct {
         vis_parse_struct! { @parse_tuple $(#[$($attrs)*])*, , $name, $($body)* }
     };
 
-    (@parse_fields $(#[$attrs:meta])*, $vis:vis, $name:ident, $($fvis:vis $fname:ident: $fty:ty),* $(,)*) => {
+    (@parse_fields
+     $(#[$attrs:meta])*, $vis:vis, $name:ident, $($fvis:vis $fname:ident: $fty:ty),* $(,)*) => {
         $(#[$attrs])* $vis struct $name { $($fvis $fname: $fty,)* }
     };
 
-    (@parse_tuple $(#[$attrs:meta])*, $vis:vis, $name:ident, $($fvis:vis $fty:ty),* $(,)*) => {
+    (@parse_tuple
+     $(#[$attrs:meta])*, $vis:vis, $name:ident, $($fvis:vis $fty:ty),* $(,)*) => {
         $(#[$attrs])* $vis struct $name ( $($fvis $fty,)* );
     };
 }