@@ -16,7 +16,7 @@ pub(super) fn print_item_tree(db: &dyn ExpandDatabase, tree: &ItemTree) -> Strin
1616 let mut p = Printer { db, tree, buf : String :: new ( ) , indent_level : 0 , needs_indent : true } ;
1717
1818 if let Some ( attrs) = tree. attrs . get ( & AttrOwner :: TopLevel ) {
19- p. print_attrs ( attrs, true ) ;
19+ p. print_attrs ( attrs, true , " \n " ) ;
2020 }
2121 p. blank ( ) ;
2222
@@ -84,22 +84,23 @@ impl Printer<'_> {
8484 }
8585 }
8686
87- fn print_attrs ( & mut self , attrs : & RawAttrs , inner : bool ) {
87+ fn print_attrs ( & mut self , attrs : & RawAttrs , inner : bool , separated_by : & str ) {
8888 let inner = if inner { "!" } else { "" } ;
8989 for attr in & * * attrs {
90- wln ! (
90+ w ! (
9191 self ,
92- "#{}[{}{}]" ,
92+ "#{}[{}{}]{} " ,
9393 inner,
9494 attr. path. display( self . db) ,
9595 attr. input. as_ref( ) . map( |it| it. to_string( ) ) . unwrap_or_default( ) ,
96+ separated_by,
9697 ) ;
9798 }
9899 }
99100
100- fn print_attrs_of ( & mut self , of : impl Into < AttrOwner > ) {
101+ fn print_attrs_of ( & mut self , of : impl Into < AttrOwner > , separated_by : & str ) {
101102 if let Some ( attrs) = self . tree . attrs . get ( & of. into ( ) ) {
102- self . print_attrs ( attrs, false ) ;
103+ self . print_attrs ( attrs, false , separated_by ) ;
103104 }
104105 }
105106
@@ -118,7 +119,7 @@ impl Printer<'_> {
118119 self . indented ( |this| {
119120 for field in fields. clone ( ) {
120121 let Field { visibility, name, type_ref, ast_id : _ } = & this. tree [ field] ;
121- this. print_attrs_of ( field) ;
122+ this. print_attrs_of ( field, " \n " ) ;
122123 this. print_visibility ( * visibility) ;
123124 w ! ( this, "{}: " , name. display( self . db) ) ;
124125 this. print_type_ref ( type_ref) ;
@@ -132,7 +133,7 @@ impl Printer<'_> {
132133 self . indented ( |this| {
133134 for field in fields. clone ( ) {
134135 let Field { visibility, name, type_ref, ast_id : _ } = & this. tree [ field] ;
135- this. print_attrs_of ( field) ;
136+ this. print_attrs_of ( field, " \n " ) ;
136137 this. print_visibility ( * visibility) ;
137138 w ! ( this, "{}: " , name. display( self . db) ) ;
138139 this. print_type_ref ( type_ref) ;
@@ -195,7 +196,7 @@ impl Printer<'_> {
195196 }
196197
197198 fn print_mod_item ( & mut self , item : ModItem ) {
198- self . print_attrs_of ( item) ;
199+ self . print_attrs_of ( item, " \n " ) ;
199200
200201 match item {
201202 ModItem :: Import ( it) => {
@@ -261,7 +262,7 @@ impl Printer<'_> {
261262 if !params. is_empty ( ) {
262263 self . indented ( |this| {
263264 for param in params. clone ( ) {
264- this. print_attrs_of ( param) ;
265+ this. print_attrs_of ( param, " \n " ) ;
265266 match & this. tree [ param] {
266267 Param :: Normal ( ty) => {
267268 if flags. contains ( FnFlags :: HAS_SELF_PARAM ) {
@@ -319,7 +320,7 @@ impl Printer<'_> {
319320 self . indented ( |this| {
320321 for variant in variants. clone ( ) {
321322 let Variant { name, fields, ast_id : _ } = & this. tree [ variant] ;
322- this. print_attrs_of ( variant) ;
323+ this. print_attrs_of ( variant, " \n " ) ;
323324 w ! ( this, "{}" , name. display( self . db) ) ;
324325 this. print_fields ( fields) ;
325326 wln ! ( this, "," ) ;
@@ -484,18 +485,20 @@ impl Printer<'_> {
484485
485486 w ! ( self , "<" ) ;
486487 let mut first = true ;
487- for ( _ , lt) in params. lifetimes . iter ( ) {
488+ for ( idx , lt) in params. lifetimes . iter ( ) {
488489 if !first {
489490 w ! ( self , ", " ) ;
490491 }
491492 first = false ;
493+ self . print_attrs_of ( idx, " " ) ;
492494 w ! ( self , "{}" , lt. name. display( self . db) ) ;
493495 }
494496 for ( idx, x) in params. type_or_consts . iter ( ) {
495497 if !first {
496498 w ! ( self , ", " ) ;
497499 }
498500 first = false ;
501+ self . print_attrs_of ( idx, " " ) ;
499502 match x {
500503 TypeOrConstParamData :: TypeParamData ( ty) => match & ty. name {
501504 Some ( name) => w ! ( self , "{}" , name. display( self . db) ) ,
0 commit comments