@@ -333,7 +333,7 @@ fn fold_struct(
333
333
sig: do astsrv:: exec ( srv) |ctxt| {
334
334
match ctxt. ast_map . get ( doc. id ( ) ) {
335
335
ast_map:: node_item( item, _) => {
336
- let item = strip_struct_drop_block ( item) ;
336
+ let item = strip_struct_extra_stuff ( item) ;
337
337
Some ( pprust:: item_to_str ( item,
338
338
extract:: interner ( ) ) )
339
339
}
@@ -344,13 +344,15 @@ fn fold_struct(
344
344
}
345
345
}
346
346
347
- /// Removes the drop block from structs so that they aren't displayed
348
- /// as part of the type
349
- fn strip_struct_drop_block ( item : @ast:: item ) -> @ast:: item {
347
+ /// Removes various things from the struct item definition that
348
+ /// shouldn't be displayed in the struct signature. Probably there
349
+ /// should be a simple pprust::struct_to_str function that does
350
+ /// what I actually want
351
+ fn strip_struct_extra_stuff( item : @ast:: item ) -> @ast:: item {
350
352
let node = match item. node {
351
353
ast:: item_class( def, tys) => {
352
354
let def = @{
353
- dtor: None ,
355
+ dtor: None , // Remove the drop { } block
354
356
.. * def
355
357
} ;
356
358
ast:: item_class ( def, tys)
@@ -359,6 +361,7 @@ fn strip_struct_drop_block(item: @ast::item) -> @ast::item {
359
361
} ;
360
362
361
363
@{
364
+ attrs: ~[ ] , // Remove the attributes
362
365
node: node,
363
366
.. * item
364
367
}
@@ -377,6 +380,13 @@ fn should_not_serialize_struct_drop_blocks() {
377
380
assert !doc. cratemod ( ) . structs ( ) [ 0 ] . sig . get ( ) . contains ( "drop" ) ;
378
381
}
379
382
383
+ #[ test]
384
+ fn should_not_serialize_struct_attrs ( ) {
385
+ // All we care about are the fields
386
+ let doc = test:: mk_doc ( ~"#[ wut] struct S { field : ( ) } ") ;
387
+ assert !doc. cratemod ( ) . structs ( ) [ 0 ] . sig . get ( ) . contains ( "wut" ) ;
388
+ }
389
+
380
390
#[ cfg( test) ]
381
391
mod test {
382
392
fn mk_doc ( source : ~str ) -> doc:: Doc {
0 commit comments