diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs index f888e29bdabb..84c909284a8f 100644 --- a/src/libsyntax/ext/tt/macro_rules.rs +++ b/src/libsyntax/ext/tt/macro_rules.rs @@ -799,7 +799,8 @@ fn is_in_follow(tok: "ed::TokenTree, frag: &str) -> Result 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) } }, diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 11becd58293b..31669e1bbe3a 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -5057,6 +5057,8 @@ impl<'a> Parser<'a> { /// 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) } diff --git a/src/test/run-pass/macro-pub-matcher.rs b/src/test/run-pass/macro-pub-matcher.rs index 7de9cc6bf21d..d5b25e6cdf2d 100644 --- a/src/test/run-pass/macro-pub-matcher.rs +++ b/src/test/run-pass/macro-pub-matcher.rs @@ -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 or the MIT license +// , 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,)* ); }; }