@@ -16,7 +16,7 @@ pub(super) fn print_item_tree(db: &dyn ExpandDatabase, tree: &ItemTree) -> Strin
16
16
let mut p = Printer { db, tree, buf : String :: new ( ) , indent_level : 0 , needs_indent : true } ;
17
17
18
18
if let Some ( attrs) = tree. attrs . get ( & AttrOwner :: TopLevel ) {
19
- p. print_attrs ( attrs, true ) ;
19
+ p. print_attrs ( attrs, true , " \n " ) ;
20
20
}
21
21
p. blank ( ) ;
22
22
@@ -84,22 +84,23 @@ impl Printer<'_> {
84
84
}
85
85
}
86
86
87
- fn print_attrs ( & mut self , attrs : & RawAttrs , inner : bool ) {
87
+ fn print_attrs ( & mut self , attrs : & RawAttrs , inner : bool , separated_by : & str ) {
88
88
let inner = if inner { "!" } else { "" } ;
89
89
for attr in & * * attrs {
90
- wln ! (
90
+ w ! (
91
91
self ,
92
- "#{}[{}{}]" ,
92
+ "#{}[{}{}]{} " ,
93
93
inner,
94
94
attr. path. display( self . db) ,
95
95
attr. input. as_ref( ) . map( |it| it. to_string( ) ) . unwrap_or_default( ) ,
96
+ separated_by,
96
97
) ;
97
98
}
98
99
}
99
100
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 ) {
101
102
if let Some ( attrs) = self . tree . attrs . get ( & of. into ( ) ) {
102
- self . print_attrs ( attrs, false ) ;
103
+ self . print_attrs ( attrs, false , separated_by ) ;
103
104
}
104
105
}
105
106
@@ -118,7 +119,7 @@ impl Printer<'_> {
118
119
self . indented ( |this| {
119
120
for field in fields. clone ( ) {
120
121
let Field { visibility, name, type_ref, ast_id : _ } = & this. tree [ field] ;
121
- this. print_attrs_of ( field) ;
122
+ this. print_attrs_of ( field, " \n " ) ;
122
123
this. print_visibility ( * visibility) ;
123
124
w ! ( this, "{}: " , name. display( self . db) ) ;
124
125
this. print_type_ref ( type_ref) ;
@@ -132,7 +133,7 @@ impl Printer<'_> {
132
133
self . indented ( |this| {
133
134
for field in fields. clone ( ) {
134
135
let Field { visibility, name, type_ref, ast_id : _ } = & this. tree [ field] ;
135
- this. print_attrs_of ( field) ;
136
+ this. print_attrs_of ( field, " \n " ) ;
136
137
this. print_visibility ( * visibility) ;
137
138
w ! ( this, "{}: " , name. display( self . db) ) ;
138
139
this. print_type_ref ( type_ref) ;
@@ -195,7 +196,7 @@ impl Printer<'_> {
195
196
}
196
197
197
198
fn print_mod_item ( & mut self , item : ModItem ) {
198
- self . print_attrs_of ( item) ;
199
+ self . print_attrs_of ( item, " \n " ) ;
199
200
200
201
match item {
201
202
ModItem :: Import ( it) => {
@@ -261,7 +262,7 @@ impl Printer<'_> {
261
262
if !params. is_empty ( ) {
262
263
self . indented ( |this| {
263
264
for param in params. clone ( ) {
264
- this. print_attrs_of ( param) ;
265
+ this. print_attrs_of ( param, " \n " ) ;
265
266
match & this. tree [ param] {
266
267
Param :: Normal ( ty) => {
267
268
if flags. contains ( FnFlags :: HAS_SELF_PARAM ) {
@@ -319,7 +320,7 @@ impl Printer<'_> {
319
320
self . indented ( |this| {
320
321
for variant in variants. clone ( ) {
321
322
let Variant { name, fields, ast_id : _ } = & this. tree [ variant] ;
322
- this. print_attrs_of ( variant) ;
323
+ this. print_attrs_of ( variant, " \n " ) ;
323
324
w ! ( this, "{}" , name. display( self . db) ) ;
324
325
this. print_fields ( fields) ;
325
326
wln ! ( this, "," ) ;
@@ -484,18 +485,20 @@ impl Printer<'_> {
484
485
485
486
w ! ( self , "<" ) ;
486
487
let mut first = true ;
487
- for ( _ , lt) in params. lifetimes . iter ( ) {
488
+ for ( idx , lt) in params. lifetimes . iter ( ) {
488
489
if !first {
489
490
w ! ( self , ", " ) ;
490
491
}
491
492
first = false ;
493
+ self . print_attrs_of ( idx, " " ) ;
492
494
w ! ( self , "{}" , lt. name. display( self . db) ) ;
493
495
}
494
496
for ( idx, x) in params. type_or_consts . iter ( ) {
495
497
if !first {
496
498
w ! ( self , ", " ) ;
497
499
}
498
500
first = false ;
501
+ self . print_attrs_of ( idx, " " ) ;
499
502
match x {
500
503
TypeOrConstParamData :: TypeParamData ( ty) => match & ty. name {
501
504
Some ( name) => w ! ( self , "{}" , name. display( self . db) ) ,
0 commit comments