Skip to content

Commit 01aebf0

Browse files
committed
implement RFC amendment 1494
1 parent 526f2bf commit 01aebf0

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

src/libsyntax/ext/tt/macro_rules.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1014,6 +1014,7 @@ fn is_in_follow(_: &ExtCtxt, tok: &Token, frag: &str) -> Result<bool, String> {
10141014
match *tok {
10151015
OpenDelim(token::DelimToken::Brace) | OpenDelim(token::DelimToken::Bracket) |
10161016
Comma | FatArrow | Colon | Eq | Gt | Semi | BinOp(token::Or) => Ok(true),
1017+
MatchNt(_, ref frag, _, _) if frag.name.as_str() == "block" => Ok(true),
10171018
Ident(i, _) if (i.name.as_str() == "as" ||
10181019
i.name.as_str() == "where") => Ok(true),
10191020
_ => Ok(false)

src/test/compile-fail/macro-follow.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ macro_rules! follow_expr {
5555
($e:expr $m:meta) => {}; //~ERROR `$e:expr` is followed by `$m:meta`
5656
}
5757
// FOLLOW(ty) = {OpenDelim(Brace), Comma, FatArrow, Colon, Eq, Gt, Semi, Or,
58-
// Ident(as), Ident(where), OpenDelim(Bracket)}
58+
// Ident(as), Ident(where), OpenDelim(Bracket), Nonterminal(Block)}
5959
macro_rules! follow_ty {
6060
($t:ty ()) => {}; //~WARN `$t:ty` is followed by `(`
6161
($t:ty []) => {}; // ok (RFC 1462)
@@ -67,7 +67,7 @@ macro_rules! follow_ty {
6767
($t:ty $t:ty) => {}; //~ERROR `$t:ty` is followed by `$t:ty`
6868
($t:ty $s:stmt) => {}; //~ERROR `$t:ty` is followed by `$s:stmt`
6969
($t:ty $p:path) => {}; //~ERROR `$t:ty` is followed by `$p:path`
70-
($t:ty $b:block) => {}; //~ERROR `$t:ty` is followed by `$b:block`
70+
($t:ty $b:block) => {}; // ok (RFC 1494)
7171
($t:ty $i:ident) => {}; //~ERROR `$t:ty` is followed by `$i:ident`
7272
($t:ty $t:tt) => {}; //~ERROR `$t:ty` is followed by `$t:tt`
7373
($t:ty $i:item) => {}; //~ERROR `$t:ty` is followed by `$i:item`
@@ -109,7 +109,7 @@ macro_rules! follow_path {
109109
($p:path $t:ty) => {}; //~ERROR `$p:path` is followed by `$t:ty`
110110
($p:path $s:stmt) => {}; //~ERROR `$p:path` is followed by `$s:stmt`
111111
($p:path $p:path) => {}; //~ERROR `$p:path` is followed by `$p:path`
112-
($p:path $b:block) => {}; //~ERROR `$p:path` is followed by `$b:block`
112+
($p:path $b:block) => {}; // ok (RFC 1494)
113113
($p:path $i:ident) => {}; //~ERROR `$p:path` is followed by `$i:ident`
114114
($p:path $t:tt) => {}; //~ERROR `$p:path` is followed by `$t:tt`
115115
($p:path $i:item) => {}; //~ERROR `$p:path` is followed by `$i:item`

src/test/run-pass/macro-follow.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ macro_rules! follow_expr {
2626
($e:expr ;) => {};
2727
}
2828
// FOLLOW(ty) = {OpenDelim(Brace), Comma, FatArrow, Colon, Eq, Gt, Semi, Or,
29-
// Ident(as), Ident(where), OpenDelim(Bracket)}
29+
// Ident(as), Ident(where), OpenDelim(Bracket), Nonterminal(Block)}
3030
macro_rules! follow_ty {
3131
($t:ty {}) => {};
3232
($t:ty ,) => {};
@@ -39,6 +39,7 @@ macro_rules! follow_ty {
3939
($t:ty as) => {};
4040
($t:ty where) => {};
4141
($t:ty []) => {};
42+
($t:ty $b:block) => {};
4243
}
4344
// FOLLOW(stmt) = FOLLOW(expr)
4445
macro_rules! follow_stmt {
@@ -59,6 +60,7 @@ macro_rules! follow_path {
5960
($p:path as) => {};
6061
($p:path where) => {};
6162
($p:path []) => {};
63+
($p:path $b:block) => {};
6264
}
6365
// FOLLOW(block) = any token
6466
macro_rules! follow_block {

0 commit comments

Comments
 (0)