File tree 4 files changed +51
-1
lines changed
4 files changed +51
-1
lines changed Original file line number Diff line number Diff line change 1
1
# This file is automatically @generated by Cargo.
2
2
# It is not intended for manual editing.
3
+ version = 3
4
+
3
5
[[package ]]
4
6
name = " addr2line"
5
7
version = " 0.14.0"
@@ -4568,6 +4570,7 @@ name = "rustdoc-json-types"
4568
4570
version = " 0.1.0"
4569
4571
dependencies = [
4570
4572
" serde" ,
4573
+ " serde_json" ,
4571
4574
]
4572
4575
4573
4576
[[package ]]
Original file line number Diff line number Diff line change @@ -242,7 +242,7 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> {
242
242
)
243
243
} )
244
244
. collect ( ) ,
245
- format_version : 4 ,
245
+ format_version : 5 ,
246
246
} ;
247
247
let mut p = self . out_path . clone ( ) ;
248
248
p. push ( output. index . get ( & output. root ) . unwrap ( ) . name . clone ( ) . unwrap ( ) ) ;
Original file line number Diff line number Diff line change @@ -9,3 +9,6 @@ path = "lib.rs"
9
9
10
10
[dependencies ]
11
11
serde = { version = " 1.0" , features = [" derive" ] }
12
+
13
+ [dev-dependencies ]
14
+ serde_json = " 1.0"
Original file line number Diff line number Diff line change @@ -508,3 +508,47 @@ pub struct Static {
508
508
pub mutable : bool ,
509
509
pub expr : String ,
510
510
}
511
+
512
+ #[ cfg( test) ]
513
+ mod tests {
514
+ use super :: * ;
515
+
516
+ #[ test]
517
+ fn test_struct_info_roundtrip ( ) {
518
+ let s = ItemEnum :: Struct ( Struct {
519
+ struct_type : StructType :: Plain ,
520
+ generics : Generics {
521
+ params : vec ! [ ] ,
522
+ where_predicates : vec ! [ ]
523
+ } ,
524
+ fields_stripped : false ,
525
+ fields : vec ! [ ] ,
526
+ impls : vec ! [ ] ,
527
+ } ) ;
528
+
529
+ let struct_json = serde_json:: to_string ( & s) . unwrap ( ) ;
530
+
531
+ let de_s = serde_json:: from_str ( & struct_json) . unwrap ( ) ;
532
+
533
+ assert_eq ! ( s, de_s) ;
534
+ }
535
+
536
+ #[ test]
537
+ fn test_union_info_roundtrip ( ) {
538
+ let u = ItemEnum :: Union ( Union {
539
+ generics : Generics {
540
+ params : vec ! [ ] ,
541
+ where_predicates : vec ! [ ]
542
+ } ,
543
+ fields_stripped : false ,
544
+ fields : vec ! [ ] ,
545
+ impls : vec ! [ ] ,
546
+ } ) ;
547
+
548
+ let union_json = serde_json:: to_string ( & u) . unwrap ( ) ;
549
+
550
+ let de_u = serde_json:: from_str ( & union_json) . unwrap ( ) ;
551
+
552
+ assert_eq ! ( u, de_u) ;
553
+ }
554
+ }
You can’t perform that action at this time.
0 commit comments