@@ -5,7 +5,7 @@ use rustc_ast_pretty::pprust;
5
5
use rustc_errors:: { Applicability , PResult } ;
6
6
use rustc_macros:: { Decodable , Encodable } ;
7
7
use rustc_session:: parse:: ParseSess ;
8
- use rustc_span:: { Ident , Span , Symbol } ;
8
+ use rustc_span:: { Ident , Span , Symbol , sym } ;
9
9
10
10
use crate :: errors;
11
11
@@ -69,15 +69,15 @@ impl MetaVarExpr {
69
69
}
70
70
71
71
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 => {
76
76
eat_dollar ( & mut iter, psess, ident. span ) ?;
77
77
MetaVarExpr :: Ignore ( parse_ident ( & mut iter, psess, ident. span ) ?)
78
78
}
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 ) ?) ,
81
81
_ => {
82
82
let err = errors:: MveUnrecognizedExpr {
83
83
span : ident. span ,
@@ -119,14 +119,13 @@ fn check_trailing_tokens<'psess>(
119
119
}
120
120
121
121
// `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 ) ,
125
125
// 1 or 2 args
126
- " count" => ( 1 , Some ( 2 ) ) ,
126
+ sym :: count => ( 1 , Some ( 2 ) ) ,
127
127
// 0 or 1 arg
128
- "index" => ( 0 , Some ( 1 ) ) ,
129
- "len" => ( 0 , Some ( 1 ) ) ,
128
+ sym:: index | sym:: len => ( 0 , Some ( 1 ) ) ,
130
129
other => unreachable ! ( "unknown MVEs should be rejected earlier (got `{other}`)" ) ,
131
130
} ;
132
131
0 commit comments