@@ -249,8 +249,9 @@ pub fn compile(
249249 def : & ast:: Item ,
250250 edition : Edition
251251) -> SyntaxExtension {
252- let lhs_nm = ast:: Ident :: from_str ( "lhs" ) . gensym ( ) ;
253- let rhs_nm = ast:: Ident :: from_str ( "rhs" ) . gensym ( ) ;
252+ let lhs_nm = ast:: Ident :: new ( sym:: lhs, def. span ) ;
253+ let rhs_nm = ast:: Ident :: new ( sym:: rhs, def. span ) ;
254+ let tt_spec = ast:: Ident :: new ( sym:: tt, def. span ) ;
254255
255256 // Parse the macro_rules! invocation
256257 let body = match def. node {
@@ -266,9 +267,9 @@ pub fn compile(
266267 let argument_gram = vec ! [
267268 quoted:: TokenTree :: Sequence ( DelimSpan :: dummy( ) , Lrc :: new( quoted:: SequenceRepetition {
268269 tts: vec![
269- quoted:: TokenTree :: MetaVarDecl ( def. span, lhs_nm, ast :: Ident :: from_str ( "tt" ) ) ,
270+ quoted:: TokenTree :: MetaVarDecl ( def. span, lhs_nm, tt_spec ) ,
270271 quoted:: TokenTree :: token( token:: FatArrow , def. span) ,
271- quoted:: TokenTree :: MetaVarDecl ( def. span, rhs_nm, ast :: Ident :: from_str ( "tt" ) ) ,
272+ quoted:: TokenTree :: MetaVarDecl ( def. span, rhs_nm, tt_spec ) ,
272273 ] ,
273274 separator: Some ( Token :: new(
274275 if body. legacy { token:: Semi } else { token:: Comma } , def. span
@@ -1115,10 +1116,9 @@ fn has_legal_fragment_specifier(sess: &ParseSess,
11151116 tok : & quoted:: TokenTree ) -> Result < ( ) , String > {
11161117 debug ! ( "has_legal_fragment_specifier({:?})" , tok) ;
11171118 if let quoted:: TokenTree :: MetaVarDecl ( _, _, ref frag_spec) = * tok {
1118- let frag_name = frag_spec. as_str ( ) ;
11191119 let frag_span = tok. span ( ) ;
1120- if !is_legal_fragment_specifier ( sess, features, attrs, & frag_name , frag_span) {
1121- return Err ( frag_name . to_string ( ) ) ;
1120+ if !is_legal_fragment_specifier ( sess, features, attrs, frag_spec . name , frag_span) {
1121+ return Err ( frag_spec . to_string ( ) ) ;
11221122 }
11231123 }
11241124 Ok ( ( ) )
@@ -1127,7 +1127,7 @@ fn has_legal_fragment_specifier(sess: &ParseSess,
11271127fn is_legal_fragment_specifier ( _sess : & ParseSess ,
11281128 _features : & Features ,
11291129 _attrs : & [ ast:: Attribute ] ,
1130- frag_name : & str ,
1130+ frag_name : Symbol ,
11311131 _frag_span : Span ) -> bool {
11321132 /*
11331133 * If new fragment specifiers are invented in nightly, `_sess`,
@@ -1136,9 +1136,9 @@ fn is_legal_fragment_specifier(_sess: &ParseSess,
11361136 * this function.
11371137 */
11381138 match frag_name {
1139- " item" | " block" | " stmt" | " expr" | " pat" | "lifetime" |
1140- " path" | "ty" | " ident" | " meta" | "tt" | "vis" | "literal" |
1141- "" => true ,
1139+ sym :: item | sym :: block | sym :: stmt | sym :: expr | sym :: pat |
1140+ sym :: lifetime | sym :: path | sym :: ty | sym :: ident | sym :: meta | sym :: tt |
1141+ sym :: vis | sym :: literal | kw :: Invalid => true ,
11421142 _ => false ,
11431143 }
11441144}
0 commit comments