@@ -16,7 +16,8 @@ use syntax::{
16
16
ast:: {
17
17
self ,
18
18
edit:: { self , AstNodeEdit } ,
19
- make, AssocItem , GenericArgList , GenericParamList , HasGenericParams , HasName ,
19
+ edit_in_place:: AttrsOwnerEdit ,
20
+ make, AssocItem , GenericArgList , GenericParamList , HasAttrs , HasGenericParams , HasName ,
20
21
HasTypeBounds , HasVisibility as astHasVisibility, Path , WherePred ,
21
22
} ,
22
23
ted:: { self , Position } ,
@@ -619,7 +620,8 @@ fn process_assoc_item(
619
620
qual_path_ty : ast:: Path ,
620
621
base_name : & str ,
621
622
) -> Option < ast:: AssocItem > {
622
- match item {
623
+ let attrs = item. attrs ( ) ;
624
+ let assoc = match item {
623
625
AssocItem :: Const ( c) => const_assoc_item ( c, qual_path_ty) ,
624
626
AssocItem :: Fn ( f) => func_assoc_item ( f, qual_path_ty, base_name) ,
625
627
AssocItem :: MacroCall ( _) => {
@@ -628,7 +630,18 @@ fn process_assoc_item(
628
630
None
629
631
}
630
632
AssocItem :: TypeAlias ( ta) => ty_assoc_item ( ta, qual_path_ty) ,
633
+ } ;
634
+ if let Some ( assoc) = & assoc {
635
+ attrs. for_each ( |attr| {
636
+ assoc. add_attr ( attr. clone ( ) ) ;
637
+ // fix indentations
638
+ if let Some ( tok) = attr. syntax ( ) . next_sibling_or_token ( ) {
639
+ let pos = Position :: after ( tok) ;
640
+ ted:: insert ( pos, make:: tokens:: whitespace ( " " ) ) ;
641
+ }
642
+ } )
631
643
}
644
+ assoc
632
645
}
633
646
634
647
fn const_assoc_item ( item : syntax:: ast:: Const , qual_path_ty : ast:: Path ) -> Option < AssocItem > {
0 commit comments