Skip to content

Commit d53e413

Browse files
committed
update :vis implementation to current rust
1 parent a248949 commit d53e413

File tree

3 files changed

+16
-17
lines changed

3 files changed

+16
-17
lines changed

src/libsyntax/ext/tt/macro_rules.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -793,13 +793,13 @@ fn is_in_follow(tok: &quoted::TokenTree, frag: &str) -> Result<bool, (String, &'
793793
"vis" => {
794794
// Explicitly disallow `priv`, on the off chance it comes back.
795795
match *tok {
796-
Comma => Ok(true),
797-
ModSep => Ok(true),
798-
MatchNt(_, ref frag, _, _) => {
799-
let name = frag.name.as_str();
800-
Ok(name == "ident" || name == "ty")
796+
TokenTree::Token(_, ref tok) => match *tok {
797+
Comma => Ok(true),
798+
ModSep => Ok(true),
799+
Ident(i) if i.name != "priv" => Ok(true),
800+
_ => Ok(false)
801801
},
802-
Ident(i, _) if i.name.as_str() != "priv" => Ok(true),
802+
TokenTree::MetaVarDecl(_, _, frag) if frag.name =="ident" || frag.name == "ty" => Ok(true),
803803
_ => Ok(false)
804804
}
805805
},

src/libsyntax/parse/parser.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5056,7 +5056,7 @@ impl<'a> Parser<'a> {
50565056
/// and `pub(super)` for `pub(in super)`. If the following element can't be a tuple (i.e. it's
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.
5059-
fn parse_visibility(&mut self, can_take_tuple: bool) -> PResult<'a, Visibility> {
5059+
pub fn parse_visibility(&mut self, can_take_tuple: bool) -> PResult<'a, Visibility> {
50605060
if !self.eat_keyword(keywords::Pub) {
50615061
return Ok(Visibility::Inherited)
50625062
}

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

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#![allow(dead_code, unused_imports)]
2-
#![feature(pub_restricted)]
32

43
/**
54
Ensure that `:vis` matches can be captured in existing positions, and passed
@@ -56,15 +55,15 @@ mod with_pub_restricted {
5655

5756
mod garden {
5857
mod with_pub_restricted_path {
59-
vis_passthru! { pub(::garden) const A: i32 = 0; }
60-
vis_passthru! { pub(::garden) enum B {} }
61-
vis_passthru! { pub(::garden) extern "C" fn c() {} }
62-
vis_passthru! { pub(::garden) mod d {} }
63-
vis_passthru! { pub(::garden) static E: i32 = 0; }
64-
vis_passthru! { pub(::garden) struct F; }
65-
vis_passthru! { pub(::garden) trait G {} }
66-
vis_passthru! { pub(::garden) type H = i32; }
67-
vis_passthru! { pub(::garden) use A as I; }
58+
vis_passthru! { pub(in garden) const A: i32 = 0; }
59+
vis_passthru! { pub(in garden) enum B {} }
60+
vis_passthru! { pub(in garden) extern "C" fn c() {} }
61+
vis_passthru! { pub(in garden) mod d {} }
62+
vis_passthru! { pub(in garden) static E: i32 = 0; }
63+
vis_passthru! { pub(in garden) struct F; }
64+
vis_passthru! { pub(in garden) trait G {} }
65+
vis_passthru! { pub(in garden) type H = i32; }
66+
vis_passthru! { pub(in garden) use A as I; }
6867
}
6968
}
7069

0 commit comments

Comments
 (0)