@@ -32,6 +32,9 @@ const EXPR_NAME_ARG_MAP: &[(&str, ArgSpec)] = &[
32
32
( "len" , ArgSpec :: Between ( 0 , 1 ) ) ,
33
33
] ;
34
34
35
+ /// List of the above for diagnostics
36
+ const VALID_METAVAR_EXPR_NAMES : & str = "`count`, `ignore`, `index`, `len`, and `concat`" ;
37
+
35
38
/// A meta-variable expression, for expansions based on properties of meta-variables.
36
39
#[ derive( Debug , PartialEq , Encodable , Decodable ) ]
37
40
pub ( crate ) enum MetaVarExpr {
@@ -99,15 +102,11 @@ impl MetaVarExpr {
99
102
"index" => MetaVarExpr :: Index ( parse_depth ( & mut iter, psess, ident. span ) ?) ,
100
103
"len" => MetaVarExpr :: Len ( parse_depth ( & mut iter, psess, ident. span ) ?) ,
101
104
_ => {
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) ) ;
111
110
}
112
111
} ;
113
112
check_trailing_tokens ( & mut iter, psess, ident) ?;
0 commit comments