@@ -5,7 +5,7 @@ use rustc_ast_pretty::pprust;
55use rustc_errors:: { Applicability , PResult } ;
66use rustc_macros:: { Decodable , Encodable } ;
77use rustc_session:: parse:: ParseSess ;
8- use rustc_span:: { Ident , Span , Symbol } ;
8+ use rustc_span:: { Ident , Span , Symbol , sym } ;
99
1010use crate :: errors;
1111
@@ -69,15 +69,15 @@ impl MetaVarExpr {
6969 }
7070
7171 let mut iter = args. iter ( ) ;
72- let rslt = match ident. as_str ( ) {
73- " concat" => parse_concat ( & mut iter, psess, outer_span, ident. span ) ?,
74- " count" => parse_count ( & mut iter, psess, ident. span ) ?,
75- " ignore" => {
72+ let rslt = match ident. name {
73+ sym :: concat => parse_concat ( & mut iter, psess, outer_span, ident. span ) ?,
74+ sym :: count => parse_count ( & mut iter, psess, ident. span ) ?,
75+ sym :: ignore => {
7676 eat_dollar ( & mut iter, psess, ident. span ) ?;
7777 MetaVarExpr :: Ignore ( parse_ident ( & mut iter, psess, ident. span ) ?)
7878 }
79- " index" => MetaVarExpr :: Index ( parse_depth ( & mut iter, psess, ident. span ) ?) ,
80- " len" => MetaVarExpr :: Len ( parse_depth ( & mut iter, psess, ident. span ) ?) ,
79+ sym :: index => MetaVarExpr :: Index ( parse_depth ( & mut iter, psess, ident. span ) ?) ,
80+ sym :: len => MetaVarExpr :: Len ( parse_depth ( & mut iter, psess, ident. span ) ?) ,
8181 _ => {
8282 let err = errors:: MveUnrecognizedExpr {
8383 span : ident. span ,
@@ -119,14 +119,13 @@ fn check_trailing_tokens<'psess>(
119119 }
120120
121121 // `None` for max indicates the arg count must be exact, `Some` indicates a range is accepted.
122- let ( min_or_exact_args, max_args) = match ident. as_str ( ) {
123- " concat" => panic ! ( "concat takes unlimited tokens but didn't eat them all" ) ,
124- " ignore" => ( 1 , None ) ,
122+ let ( min_or_exact_args, max_args) = match ident. name {
123+ sym :: concat => panic ! ( "concat takes unlimited tokens but didn't eat them all" ) ,
124+ sym :: ignore => ( 1 , None ) ,
125125 // 1 or 2 args
126- " count" => ( 1 , Some ( 2 ) ) ,
126+ sym :: count => ( 1 , Some ( 2 ) ) ,
127127 // 0 or 1 arg
128- "index" => ( 0 , Some ( 1 ) ) ,
129- "len" => ( 0 , Some ( 1 ) ) ,
128+ sym:: index | sym:: len => ( 0 , Some ( 1 ) ) ,
130129 other => unreachable ! ( "unknown MVEs should be rejected earlier (got `{other}`)" ) ,
131130 } ;
132131
0 commit comments