@@ -249,8 +249,9 @@ pub fn compile(
249
249
def : & ast:: Item ,
250
250
edition : Edition
251
251
) -> 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 ) ;
254
255
255
256
// Parse the macro_rules! invocation
256
257
let body = match def. node {
@@ -266,9 +267,9 @@ pub fn compile(
266
267
let argument_gram = vec ! [
267
268
quoted:: TokenTree :: Sequence ( DelimSpan :: dummy( ) , Lrc :: new( quoted:: SequenceRepetition {
268
269
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 ) ,
270
271
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 ) ,
272
273
] ,
273
274
separator: Some ( Token :: new(
274
275
if body. legacy { token:: Semi } else { token:: Comma } , def. span
@@ -1115,10 +1116,9 @@ fn has_legal_fragment_specifier(sess: &ParseSess,
1115
1116
tok : & quoted:: TokenTree ) -> Result < ( ) , String > {
1116
1117
debug ! ( "has_legal_fragment_specifier({:?})" , tok) ;
1117
1118
if let quoted:: TokenTree :: MetaVarDecl ( _, _, ref frag_spec) = * tok {
1118
- let frag_name = frag_spec. as_str ( ) ;
1119
1119
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 ( ) ) ;
1122
1122
}
1123
1123
}
1124
1124
Ok ( ( ) )
@@ -1127,7 +1127,7 @@ fn has_legal_fragment_specifier(sess: &ParseSess,
1127
1127
fn is_legal_fragment_specifier ( _sess : & ParseSess ,
1128
1128
_features : & Features ,
1129
1129
_attrs : & [ ast:: Attribute ] ,
1130
- frag_name : & str ,
1130
+ frag_name : Symbol ,
1131
1131
_frag_span : Span ) -> bool {
1132
1132
/*
1133
1133
* If new fragment specifiers are invented in nightly, `_sess`,
@@ -1136,9 +1136,9 @@ fn is_legal_fragment_specifier(_sess: &ParseSess,
1136
1136
* this function.
1137
1137
*/
1138
1138
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 ,
1142
1142
_ => false ,
1143
1143
}
1144
1144
}
0 commit comments