@@ -11,14 +11,7 @@ use syn::parse::{Error as SynError, Result as SynResult};
11
11
/// See the crate-level documentation for SNAFU which contains tested
12
12
/// examples of this macro.
13
13
14
- #[ cfg_attr(
15
- not( feature = "unstable_display_attribute" ) ,
16
- proc_macro_derive( Snafu , attributes( snafu_visibility, snafu_display) )
17
- ) ]
18
- #[ cfg_attr(
19
- feature = "unstable_display_attribute" ,
20
- proc_macro_derive( Snafu , attributes( snafu_visibility, snafu:: display, snafu_display) )
21
- ) ]
14
+ #[ proc_macro_derive( Snafu , attributes( snafu_visibility, snafu_display) ) ]
22
15
pub fn snafu_derive ( input : TokenStream ) -> TokenStream {
23
16
let ast = syn:: parse ( input) . expect ( "Could not parse type to derive Error for" ) ;
24
17
@@ -144,18 +137,6 @@ fn parse_snafu_information(ty: syn::DeriveInput) -> SynResult<EnumInfo> {
144
137
} )
145
138
}
146
139
147
- fn is_snafu_display ( p : & syn:: Path ) -> bool {
148
- is_path ( p, & [ "snafu" , "display" ] )
149
- }
150
-
151
- fn is_path ( p : & syn:: Path , parts : & [ & str ] ) -> bool {
152
- p. segments
153
- . iter ( )
154
- . zip ( parts)
155
- . map ( |( a, b) | a. ident == b)
156
- . all ( |b| b)
157
- }
158
-
159
140
fn parse_snafu_visibility ( attrs : & [ syn:: Attribute ] ) -> SynResult < Option < Box < quote:: ToTokens > > > {
160
141
use syn:: spanned:: Spanned ;
161
142
use syn:: Meta ;
@@ -206,9 +187,7 @@ fn parse_snafu_display(attrs: &[syn::Attribute]) -> SynResult<Option<DisplayForm
206
187
attrs
207
188
. into_iter ( )
208
189
. flat_map ( |attr| {
209
- if is_snafu_display ( & attr. path ) {
210
- Some ( parse_snafu_display_beautiful ( attr) )
211
- } else if attr. path . is_ident ( "snafu_display" ) {
190
+ if attr. path . is_ident ( "snafu_display" ) {
212
191
let meta = match attr. parse_meta ( ) {
213
192
Ok ( meta) => meta,
214
193
Err ( e) => return Some ( Err ( e) ) ,
@@ -231,24 +210,6 @@ fn parse_snafu_display(attrs: &[syn::Attribute]) -> SynResult<Option<DisplayForm
231
210
. my_transpose ( )
232
211
}
233
212
234
- fn parse_snafu_display_beautiful ( attr : & syn:: Attribute ) -> SynResult < DisplayFormat > {
235
- use syn:: spanned:: Spanned ;
236
- use syn:: Expr ;
237
-
238
- let expr: Expr = syn:: parse2 ( attr. tts . clone ( ) ) ?;
239
- let expr: Box < quote:: ToTokens > = match expr {
240
- Expr :: Tuple ( expr_tuple) => Box :: new ( expr_tuple. elems ) ,
241
- Expr :: Paren ( expr_paren) => Box :: new ( expr_paren. expr ) ,
242
- _ => {
243
- return Err ( SynError :: new (
244
- expr. span ( ) ,
245
- "A parenthesized format string with optional values is expected" ,
246
- ) ) ;
247
- }
248
- } ;
249
- Ok ( DisplayFormat :: Direct ( expr) )
250
- }
251
-
252
213
fn parse_snafu_display_nested ( meta : syn:: MetaList ) -> SynResult < DisplayFormat > {
253
214
use syn:: spanned:: Spanned ;
254
215
use syn:: { Expr , Lit , NestedMeta } ;
0 commit comments