File tree Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -53,12 +53,11 @@ fn is_derive(attr: &ast::Attribute) -> bool {
53
53
}
54
54
55
55
/// Returns the arguments of `#[derive(...)]`.
56
- fn get_derive_spans ( attr : & ast:: Attribute ) -> Option < Vec < Span > > {
56
+ fn get_derive_spans < ' a > ( attr : & ' a ast:: Attribute ) -> Option < impl Iterator < Item = Span > + ' a > {
57
57
attr. meta_item_list ( ) . map ( |meta_item_list| {
58
58
meta_item_list
59
- . iter ( )
59
+ . into_iter ( )
60
60
. map ( |nested_meta_item| nested_meta_item. span )
61
- . collect ( )
62
61
} )
63
62
}
64
63
@@ -411,10 +410,11 @@ impl<'a> Rewrite for [ast::Attribute] {
411
410
// Handle derives if we will merge them.
412
411
if context. config . merge_derives ( ) && is_derive ( & attrs[ 0 ] ) {
413
412
let derives = take_while_with_pred ( context, attrs, is_derive) ;
414
- let mut derive_spans = vec ! [ ] ;
415
- for derive in derives {
416
- derive_spans. append ( & mut get_derive_spans ( derive) ?) ;
417
- }
413
+ let derive_spans: Vec < _ > = derives
414
+ . iter ( )
415
+ . filter_map ( get_derive_spans)
416
+ . flatten ( )
417
+ . collect ( ) ;
418
418
let derive_str =
419
419
format_derive ( & derive_spans, attr_prefix ( & attrs[ 0 ] ) , shape, context) ?;
420
420
result. push_str ( & derive_str) ;
You can’t perform that action at this time.
0 commit comments