@@ -21,6 +21,9 @@ const EXPR_NAME_ARG_MAP: &[(&str, Option<usize>)] = &[
21
21
( "len" , Some ( 2 ) ) ,
22
22
] ;
23
23
24
+ /// List of the above for diagnostics
25
+ const VALID_METAVAR_EXPR_NAMES : & str = "`count`, `ignore`, `index`, `len`, and `concat`" ;
26
+
24
27
/// A meta-variable expression, for expansions based on properties of meta-variables.
25
28
#[ derive( Debug , PartialEq , Encodable , Decodable ) ]
26
29
pub ( crate ) enum MetaVarExpr {
@@ -89,15 +92,11 @@ impl MetaVarExpr {
89
92
"index" => MetaVarExpr :: Index ( parse_depth ( & mut iter, psess, ident. span ) ?) ,
90
93
"len" => MetaVarExpr :: Len ( parse_depth ( & mut iter, psess, ident. span ) ?) ,
91
94
_ => {
92
- let err_msg = "unrecognized meta-variable expression" ;
93
- let mut err = psess. dcx ( ) . struct_span_err ( ident. span , err_msg) ;
94
- err. span_suggestion (
95
- ident. span ,
96
- "supported expressions are count, ignore, index and len" ,
97
- "" ,
98
- Applicability :: MachineApplicable ,
99
- ) ;
100
- return Err ( err) ;
95
+ let err = errors:: MveUnrecognizedExpr {
96
+ span : ident. span ,
97
+ valid_expr_list : VALID_METAVAR_EXPR_NAMES ,
98
+ } ;
99
+ return Err ( psess. dcx ( ) . create_err ( err) ) ;
101
100
}
102
101
} ;
103
102
check_trailing_tokens ( & mut iter, psess, ident) ?;
0 commit comments