@@ -877,9 +877,9 @@ fn check_matcher_core(
877877 // Now `last` holds the complete set of NT tokens that could
878878 // end the sequence before SUFFIX. Check that every one works with `suffix`.
879879 ' each_last: for token in & last. tokens {
880- if let TokenTree :: MetaVarDecl ( _, ref name, ref frag_spec) = * token {
880+ if let TokenTree :: MetaVarDecl ( _, name, frag_spec) = * token {
881881 for next_token in & suffix_first. tokens {
882- match is_in_follow ( next_token, & frag_spec. as_str ( ) ) {
882+ match is_in_follow ( next_token, frag_spec. name ) {
883883 IsInFollow :: Invalid ( msg, help) => {
884884 sess. span_diagnostic
885885 . struct_span_err ( next_token. span ( ) , & msg)
@@ -948,7 +948,7 @@ fn check_matcher_core(
948948
949949fn token_can_be_followed_by_any ( tok : & quoted:: TokenTree ) -> bool {
950950 if let quoted:: TokenTree :: MetaVarDecl ( _, _, frag_spec) = * tok {
951- frag_can_be_followed_by_any ( & frag_spec. as_str ( ) )
951+ frag_can_be_followed_by_any ( frag_spec. name )
952952 } else {
953953 // (Non NT's can always be followed by anthing in matchers.)
954954 true
@@ -963,15 +963,15 @@ fn token_can_be_followed_by_any(tok: "ed::TokenTree) -> bool {
963963/// specifier which consumes at most one token tree can be followed by
964964/// a fragment specifier (indeed, these fragments can be followed by
965965/// ANYTHING without fear of future compatibility hazards).
966- fn frag_can_be_followed_by_any ( frag : & str ) -> bool {
966+ fn frag_can_be_followed_by_any ( frag : Symbol ) -> bool {
967967 match frag {
968- " item" | // always terminated by `}` or `;`
969- " block" | // exactly one token tree
970- " ident" | // exactly one token tree
971- " literal" | // exactly one token tree
972- " meta" | // exactly one token tree
973- " lifetime" | // exactly one token tree
974- "tt" => // exactly one token tree
968+ sym :: item | // always terminated by `}` or `;`
969+ sym :: block | // exactly one token tree
970+ sym :: ident | // exactly one token tree
971+ sym :: literal | // exactly one token tree
972+ sym :: meta | // exactly one token tree
973+ sym :: lifetime | // exactly one token tree
974+ sym :: tt => // exactly one token tree
975975 true ,
976976
977977 _ =>
@@ -993,7 +993,7 @@ enum IsInFollow {
993993/// break macros that were relying on that binary operator as a
994994/// separator.
995995// when changing this do not forget to update doc/book/macros.md!
996- fn is_in_follow ( tok : & quoted:: TokenTree , frag : & str ) -> IsInFollow {
996+ fn is_in_follow ( tok : & quoted:: TokenTree , frag : Symbol ) -> IsInFollow {
997997 use quoted:: TokenTree ;
998998
999999 if let TokenTree :: Token ( Token { kind : token:: CloseDelim ( _) , .. } ) = * tok {
@@ -1002,17 +1002,17 @@ fn is_in_follow(tok: "ed::TokenTree, frag: &str) -> IsInFollow {
10021002 IsInFollow :: Yes
10031003 } else {
10041004 match frag {
1005- " item" => {
1005+ sym :: item => {
10061006 // since items *must* be followed by either a `;` or a `}`, we can
10071007 // accept anything after them
10081008 IsInFollow :: Yes
10091009 }
1010- " block" => {
1010+ sym :: block => {
10111011 // anything can follow block, the braces provide an easy boundary to
10121012 // maintain
10131013 IsInFollow :: Yes
10141014 }
1015- " stmt" | " expr" => {
1015+ sym :: stmt | sym :: expr => {
10161016 const TOKENS : & [ & str ] = & [ "`=>`" , "`,`" , "`;`" ] ;
10171017 match tok {
10181018 TokenTree :: Token ( token) => match token. kind {
@@ -1022,7 +1022,7 @@ fn is_in_follow(tok: "ed::TokenTree, frag: &str) -> IsInFollow {
10221022 _ => IsInFollow :: No ( TOKENS ) ,
10231023 }
10241024 }
1025- " pat" => {
1025+ sym :: pat => {
10261026 const TOKENS : & [ & str ] = & [ "`=>`" , "`,`" , "`=`" , "`|`" , "`if`" , "`in`" ] ;
10271027 match tok {
10281028 TokenTree :: Token ( token) => match token. kind {
@@ -1033,7 +1033,7 @@ fn is_in_follow(tok: "ed::TokenTree, frag: &str) -> IsInFollow {
10331033 _ => IsInFollow :: No ( TOKENS ) ,
10341034 }
10351035 }
1036- " path" | "ty" => {
1036+ sym :: path | sym :: ty => {
10371037 const TOKENS : & [ & str ] = & [
10381038 "`{`" , "`[`" , "`=>`" , "`,`" , "`>`" , "`=`" , "`:`" , "`;`" , "`|`" , "`as`" ,
10391039 "`where`" ,
@@ -1061,20 +1061,20 @@ fn is_in_follow(tok: "ed::TokenTree, frag: &str) -> IsInFollow {
10611061 _ => IsInFollow :: No ( TOKENS ) ,
10621062 }
10631063 }
1064- " ident" | " lifetime" => {
1064+ sym :: ident | sym :: lifetime => {
10651065 // being a single token, idents and lifetimes are harmless
10661066 IsInFollow :: Yes
10671067 }
1068- " literal" => {
1068+ sym :: literal => {
10691069 // literals may be of a single token, or two tokens (negative numbers)
10701070 IsInFollow :: Yes
10711071 }
1072- " meta" | "tt" => {
1072+ sym :: meta | sym :: tt => {
10731073 // being either a single token or a delimited sequence, tt is
10741074 // harmless
10751075 IsInFollow :: Yes
10761076 }
1077- " vis" => {
1077+ sym :: vis => {
10781078 // Explicitly disallow `priv`, on the off chance it comes back.
10791079 const TOKENS : & [ & str ] = & [ "`,`" , "an ident" , "a type" ] ;
10801080 match tok {
@@ -1099,7 +1099,7 @@ fn is_in_follow(tok: "ed::TokenTree, frag: &str) -> IsInFollow {
10991099 _ => IsInFollow :: No ( TOKENS ) ,
11001100 }
11011101 }
1102- "" => IsInFollow :: Yes , // kw::Invalid
1102+ kw :: Invalid => IsInFollow :: Yes ,
11031103 _ => IsInFollow :: Invalid (
11041104 format ! ( "invalid fragment specifier `{}`" , frag) ,
11051105 VALID_FRAGMENT_NAMES_MSG ,
0 commit comments