@@ -32,6 +32,9 @@ const EXPR_NAME_ARG_MAP: &[(&str, ArgSpec)] = &[
3232 ( "len" , ArgSpec :: Between ( 0 , 1 ) ) ,
3333] ;
3434
35+ /// List of the above for diagnostics
36+ const VALID_METAVAR_EXPR_NAMES : & str = "`count`, `ignore`, `index`, `len`, and `concat`" ;
37+
3538/// A meta-variable expression, for expansions based on properties of meta-variables.
3639#[ derive( Debug , PartialEq , Encodable , Decodable ) ]
3740pub ( crate ) enum MetaVarExpr {
@@ -99,15 +102,11 @@ impl MetaVarExpr {
99102 "index" => MetaVarExpr :: Index ( parse_depth ( & mut iter, psess, ident. span ) ?) ,
100103 "len" => MetaVarExpr :: Len ( parse_depth ( & mut iter, psess, ident. span ) ?) ,
101104 _ => {
102- let err_msg = "unrecognized meta-variable expression" ;
103- let mut err = psess. dcx ( ) . struct_span_err ( ident. span , err_msg) ;
104- err. span_suggestion (
105- ident. span ,
106- "supported expressions are count, ignore, index and len" ,
107- "" ,
108- Applicability :: MachineApplicable ,
109- ) ;
110- return Err ( err) ;
105+ let err = errors:: MveUnrecognizedExpr {
106+ span : ident. span ,
107+ valid_expr_list : VALID_METAVAR_EXPR_NAMES ,
108+ } ;
109+ return Err ( psess. dcx ( ) . create_err ( err) ) ;
111110 }
112111 } ;
113112 check_trailing_tokens ( & mut iter, psess, ident) ?;
0 commit comments