File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -333,6 +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
337
Some ( pprust:: item_to_str ( item,
337
338
extract:: interner ( ) ) )
338
339
}
@@ -343,12 +344,39 @@ fn fold_struct(
343
344
}
344
345
}
345
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 {
350
+ let node = match item. node {
351
+ ast:: item_class( def, tys) => {
352
+ let def = @{
353
+ dtor: None ,
354
+ .. * def
355
+ } ;
356
+ ast:: item_class ( def, tys)
357
+ }
358
+ _ => fail ~"not a struct "
359
+ } ;
360
+
361
+ @{
362
+ node: node,
363
+ .. * item
364
+ }
365
+ }
366
+
346
367
#[ test]
347
368
fn should_add_struct_defs ( ) {
348
369
let doc = test:: mk_doc ( ~"struct S { field : ( ) } ") ;
349
370
assert doc. cratemod ( ) . structs ( ) [ 0 ] . sig . get ( ) . contains ( "struct S {" ) ;
350
371
}
351
372
373
+ #[ test]
374
+ fn should_not_serialize_struct_drop_blocks ( ) {
375
+ // All we care about are the fields
376
+ let doc = test:: mk_doc ( ~"struct S { field : ( ) , drop { } } ") ;
377
+ assert !doc. cratemod ( ) . structs ( ) [ 0 ] . sig . get ( ) . contains ( "drop" ) ;
378
+ }
379
+
352
380
#[ cfg( test) ]
353
381
mod test {
354
382
fn mk_doc ( source : ~str ) -> doc:: Doc {
You can’t perform that action at this time.
0 commit comments