@@ -76,31 +76,31 @@ fn find_relative_libdir(sysroot: &Path) -> std::borrow::Cow<'static, str> {
7676macro_rules! target_spec_enum {
7777 (
7878 $( #[ $attr: meta] ) *
79- pub enum $name : ident {
79+ pub enum $Name : ident {
8080 $(
8181 $( #[ $variant_attr: meta] ) *
82- $variant : ident = $string: literal,
82+ $Variant : ident = $string: literal,
8383 ) *
8484 }
8585 parse_error_type = $parse_error_type: literal;
8686 ) => {
8787 $( #[ $attr] ) *
8888 #[ derive( Clone , Copy , PartialEq , Eq , Hash , Debug , PartialOrd , Ord ) ]
8989 #[ derive( schemars:: JsonSchema ) ]
90- pub enum $name {
90+ pub enum $Name {
9191 $(
9292 $( #[ $variant_attr] ) *
9393 #[ serde( rename = $string) ] // for JSON schema generation only
94- $variant ,
94+ $Variant ,
9595 ) *
9696 }
9797
98- impl FromStr for $name {
98+ impl FromStr for $Name {
9999 type Err = String ;
100100
101101 fn from_str( s: & str ) -> Result <Self , Self :: Err > {
102102 Ok ( match s {
103- $( $string => Self :: $variant , ) *
103+ $( $string => Self :: $Variant , ) *
104104 _ => {
105105 let all = [ $( concat!( "'" , $string, "'" ) ) ,* ] . join( ", " ) ;
106106 return Err ( format!( "invalid {}: '{s}'. allowed values: {all}" , $parse_error_type) ) ;
@@ -109,24 +109,25 @@ macro_rules! target_spec_enum {
109109 }
110110 }
111111
112- impl $name {
112+ impl $Name {
113+ pub const ALL : & ' static [ $Name] = & [ $( $Name:: $Variant, ) * ] ;
113114 pub fn desc( & self ) -> & ' static str {
114115 match self {
115- $( Self :: $variant => $string, ) *
116+ $( Self :: $Variant => $string, ) *
116117 }
117118 }
118119 }
119120
120- impl crate :: json:: ToJson for $name {
121+ impl crate :: json:: ToJson for $Name {
121122 fn to_json( & self ) -> crate :: json:: Json {
122123 self . desc( ) . to_json( )
123124 }
124125 }
125126
126- crate :: json:: serde_deserialize_from_str!( $name ) ;
127+ crate :: json:: serde_deserialize_from_str!( $Name ) ;
127128
128129
129- impl std:: fmt:: Display for $name {
130+ impl std:: fmt:: Display for $Name {
130131 fn fmt( & self , f: & mut std:: fmt:: Formatter <' _>) -> std:: fmt:: Result {
131132 f. write_str( self . desc( ) )
132133 }
0 commit comments