11// Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
22// SPDX-License-Identifier: Apache-2.0
33
4+ #![ allow( clippy:: missing_safety_doc) ]
5+
46extern crate versionize;
57extern crate versionize_derive;
68extern crate vmm_sys_util;
@@ -14,7 +16,7 @@ use vmm_sys_util::generate_fam_struct_impl;
1416use versionize:: { VersionMap , Versionize , VersionizeError , VersionizeResult } ;
1517use versionize_derive:: Versionize ;
1618
17- #[ derive( Debug , PartialEq , Versionize ) ]
19+ #[ derive( Debug , PartialEq , Versionize , Eq ) ]
1820pub enum TestState {
1921 Zero ,
2022 One ( u32 ) ,
@@ -149,6 +151,7 @@ fn test_hardcoded_struct_deserialization() {
149151 option_1 : Option < u8 > ,
150152 #[ version( start = 3 , end = 4 , default_fn = "default_vec" ) ]
151153 vec_1 : Vec < char > ,
154+ #[ allow( clippy:: box_collection) ] // we want to explicitly test Box
152155 box_1 : Box < String > ,
153156 #[ version( start = 3 ) ]
154157 wrapping_1 : Wrapping < u32 > ,
@@ -353,7 +356,7 @@ fn test_hardcoded_enum_deserialization() {
353356 ) ;
354357}
355358
356- #[ derive( Debug , PartialEq , Versionize ) ]
359+ #[ derive( Debug , PartialEq , Eq , Versionize ) ]
357360pub struct A {
358361 a : u32 ,
359362 #[ version( start = 1 , end = 2 ) ]
@@ -362,7 +365,7 @@ pub struct A {
362365 c : String ,
363366}
364367
365- #[ derive( Debug , PartialEq , Versionize ) ]
368+ #[ derive( Debug , PartialEq , Eq , Versionize ) ]
366369pub struct X {
367370 x : bool ,
368371 a_1 : A ,
@@ -380,7 +383,7 @@ impl A {
380383
381384impl X {
382385 fn default_y ( _source_version : u16 ) -> Box < usize > {
383- Box :: from ( 4 as usize )
386+ Box :: from ( 4 )
384387 }
385388
386389 fn default_z ( _source_version : u16 ) -> Vec < u8 > {
@@ -441,7 +444,7 @@ fn test_nested_structs_deserialization() {
441444 b : Some ( TestState :: One ( 4 ) ) ,
442445 c : "some_string" . to_owned ( ) ,
443446 } ,
444- y : Box :: from ( 2 as usize ) ,
447+ y : Box :: from ( 2 ) ,
445448 z : vec ! [ 16 , 4 ] ,
446449 } ;
447450 assert_eq ! ( restored_state, expected_state) ;
@@ -458,7 +461,7 @@ fn test_nested_structs_deserialization() {
458461 b : None ,
459462 c : "random" . to_owned ( ) ,
460463 } ,
461- y : Box :: from ( 2 as usize ) ,
464+ y : Box :: from ( 2 ) ,
462465 z : vec ! [ 16 , 4 ] ,
463466 } ;
464467 assert_eq ! ( restored_state, expected_state) ;
@@ -475,7 +478,7 @@ fn test_nested_structs_deserialization() {
475478 b : None ,
476479 c : "random" . to_owned ( ) ,
477480 } ,
478- y : Box :: from ( 4 as usize ) ,
481+ y : Box :: from ( 4 ) ,
479482 z : vec ! [ 24 ; 4 ] ,
480483 } ;
481484 assert_eq ! ( restored_state, expected_state) ;
@@ -514,7 +517,7 @@ fn test_versionize_struct_with_array() {
514517 assert_eq ! ( restored_test_struct, test_struct) ;
515518}
516519
517- #[ derive( Clone , Debug , PartialEq , Versionize ) ]
520+ #[ derive( Clone , Debug , PartialEq , Eq , Versionize ) ]
518521pub enum DeviceStatus {
519522 Inactive ,
520523 Active ,
@@ -528,7 +531,7 @@ impl Default for DeviceStatus {
528531 }
529532}
530533
531- #[ derive( Clone , Debug , PartialEq , Versionize ) ]
534+ #[ derive( Clone , Debug , PartialEq , Eq , Versionize ) ]
532535pub enum OperationSupported {
533536 Add ,
534537 Remove ,
@@ -567,7 +570,7 @@ impl OperationSupported {
567570 }
568571}
569572
570- #[ derive( Clone , Debug , PartialEq , Versionize ) ]
573+ #[ derive( Clone , Debug , PartialEq , Eq , Versionize ) ]
571574pub struct Device {
572575 name : String ,
573576 id : Wrapping < u32 > ,
@@ -633,7 +636,7 @@ impl Device {
633636 assert ! ( target_version < 2 ) ;
634637 self . some_params . push ( "active" . to_owned ( ) ) ;
635638 self . some_params
636- . retain ( |x| x. clone ( ) != "inactive" . to_owned ( ) ) ;
639+ . retain ( |x| x. clone ( ) != * "inactive" ) ;
637640 Ok ( ( ) )
638641 }
639642
@@ -782,7 +785,7 @@ fn test_versionize_struct_with_enums() {
782785 ) ;
783786}
784787
785- #[ derive( Clone , Debug , PartialEq , Versionize ) ]
788+ #[ derive( Clone , Debug , PartialEq , Eq , Versionize ) ]
786789pub enum State {
787790 Zero ,
788791 One ( bool ) ,
0 commit comments