File tree Expand file tree Collapse file tree 4 files changed +51
-1
lines changed Expand file tree Collapse file tree 4 files changed +51
-1
lines changed Original file line number Diff line number Diff line change 11# This file is automatically @generated by Cargo.
22# It is not intended for manual editing.
3+ version = 3
4+
35[[package ]]
46name = " addr2line"
57version = " 0.14.0"
@@ -4568,6 +4570,7 @@ name = "rustdoc-json-types"
45684570version = " 0.1.0"
45694571dependencies = [
45704572 " serde" ,
4573+ " serde_json" ,
45714574]
45724575
45734576[[package ]]
Original file line number Diff line number Diff line change @@ -242,7 +242,7 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> {
242242 )
243243 } )
244244 . collect ( ) ,
245- format_version : 4 ,
245+ format_version : 5 ,
246246 } ;
247247 let mut p = self . out_path . clone ( ) ;
248248 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"
99
1010[dependencies ]
1111serde = { 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 {
508508 pub mutable : bool ,
509509 pub expr : String ,
510510}
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