Skip to content

Commit 16010c2

Browse files
committed
parse interpolated visibility tokens
1 parent 06411c4 commit 16010c2

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

src/libsyntax/ext/tt/macro_rules.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -799,7 +799,8 @@ fn is_in_follow(tok: &quoted::TokenTree, frag: &str) -> Result<bool, (String, &'
799799
Ident(i) if i.name != "priv" => Ok(true),
800800
_ => Ok(false)
801801
},
802-
TokenTree::MetaVarDecl(_, _, frag) if frag.name =="ident" || frag.name == "ty" => Ok(true),
802+
TokenTree::MetaVarDecl(_, _, frag)
803+
if frag.name =="ident" || frag.name == "ty" => Ok(true),
803804
_ => Ok(false)
804805
}
805806
},

src/libsyntax/parse/parser.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5057,6 +5057,8 @@ impl<'a> Parser<'a> {
50575057
/// a function definition, it's not a tuple struct field) and the contents within the parens
50585058
/// isn't valid, emit a proper diagnostic.
50595059
pub fn parse_visibility(&mut self, can_take_tuple: bool) -> PResult<'a, Visibility> {
5060+
maybe_whole!(self, NtVis, |x| x);
5061+
50605062
if !self.eat_keyword(keywords::Pub) {
50615063
return Ok(Visibility::Inherited)
50625064
}

src/test/run-pass/macro-pub-matcher.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
111
#![allow(dead_code, unused_imports)]
212

313
/**
@@ -96,11 +106,13 @@ macro_rules! vis_parse_struct {
96106
vis_parse_struct! { @parse_tuple $(#[$($attrs)*])*, , $name, $($body)* }
97107
};
98108

99-
(@parse_fields $(#[$attrs:meta])*, $vis:vis, $name:ident, $($fvis:vis $fname:ident: $fty:ty),* $(,)*) => {
109+
(@parse_fields
110+
$(#[$attrs:meta])*, $vis:vis, $name:ident, $($fvis:vis $fname:ident: $fty:ty),* $(,)*) => {
100111
$(#[$attrs])* $vis struct $name { $($fvis $fname: $fty,)* }
101112
};
102113

103-
(@parse_tuple $(#[$attrs:meta])*, $vis:vis, $name:ident, $($fvis:vis $fty:ty),* $(,)*) => {
114+
(@parse_tuple
115+
$(#[$attrs:meta])*, $vis:vis, $name:ident, $($fvis:vis $fty:ty),* $(,)*) => {
104116
$(#[$attrs])* $vis struct $name ( $($fvis $fty,)* );
105117
};
106118
}

0 commit comments

Comments
 (0)