Skip to content

Commit 3c37a95

Browse files
Updates of the fix
1 parent c821e5c commit 3c37a95

File tree

1 file changed

+43
-43
lines changed

1 file changed

+43
-43
lines changed

src/libsyntax/ext/tt/macro_rules.rs

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -413,48 +413,48 @@ fn check_matcher<'a, I>(cx: &mut ExtCtxt, matcher: I, follow: &Token)
413413

414414
fn is_in_follow(_: &ExtCtxt, tok: &Token, frag: &str) -> Result<bool, String> {
415415
if let &CloseDelim(_) = tok {
416-
return Ok(true);
416+
Ok(true)
417+
} else {
418+
match frag {
419+
"item" => {
420+
// since items *must* be followed by either a `;` or a `}`, we can
421+
// accept anything after them
422+
Ok(true)
423+
},
424+
"block" => {
425+
// anything can follow block, the braces provide a easy boundary to
426+
// maintain
427+
Ok(true)
428+
},
429+
"stmt" | "expr" => {
430+
match *tok {
431+
FatArrow | Comma | Semi => Ok(true),
432+
_ => Ok(false)
433+
}
434+
},
435+
"pat" => {
436+
match *tok {
437+
FatArrow | Comma | Eq => Ok(true),
438+
_ => Ok(false)
439+
}
440+
},
441+
"path" | "ty" => {
442+
match *tok {
443+
Comma | FatArrow | Colon | Eq | Gt => Ok(true),
444+
Ident(i, _) if i.as_str() == "as" => Ok(true),
445+
_ => Ok(false)
446+
}
447+
},
448+
"ident" => {
449+
// being a single token, idents are harmless
450+
Ok(true)
451+
},
452+
"meta" | "tt" => {
453+
// being either a single token or a delimited sequence, tt is
454+
// harmless
455+
Ok(true)
456+
},
457+
_ => Err(format!("unrecognized builtin nonterminal `{}`", frag))
458+
}
417459
}
418-
419-
Ok(match frag {
420-
"item" => {
421-
// since items *must* be followed by either a `;` or a `}`, we can
422-
// accept anything after them
423-
true
424-
},
425-
"block" => {
426-
// anything can follow block, the braces provide a easy boundary to
427-
// maintain
428-
true
429-
},
430-
"stmt" | "expr" => {
431-
match *tok {
432-
FatArrow | Comma | Semi => true,
433-
_ => false
434-
}
435-
},
436-
"pat" => {
437-
match *tok {
438-
FatArrow | Comma | Eq => true,
439-
_ => false
440-
}
441-
},
442-
"path" | "ty" => {
443-
match *tok {
444-
Comma | FatArrow | Colon | Eq | Gt => true,
445-
Ident(i, _) if i.as_str() == "as" => true,
446-
_ => false
447-
}
448-
},
449-
"ident" => {
450-
// being a single token, idents are harmless
451-
true
452-
},
453-
"meta" | "tt" => {
454-
// being either a single token or a delimited sequence, tt is
455-
// harmless
456-
true
457-
},
458-
_ => return Err(format!("unrecognized builtin nonterminal `{}`", frag)),
459-
})
460460
}

0 commit comments

Comments
 (0)