1
1
// Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
// SPDX-License-Identifier: Apache-2.0
3
3
4
+ #![ allow( clippy:: missing_safety_doc) ]
5
+
4
6
extern crate versionize;
5
7
extern crate versionize_derive;
6
8
extern crate vmm_sys_util;
@@ -14,7 +16,7 @@ use vmm_sys_util::generate_fam_struct_impl;
14
16
use versionize:: { VersionMap , Versionize , VersionizeError , VersionizeResult } ;
15
17
use versionize_derive:: Versionize ;
16
18
17
- #[ derive( Debug , PartialEq , Versionize ) ]
19
+ #[ derive( Debug , PartialEq , Versionize , Eq ) ]
18
20
pub enum TestState {
19
21
Zero ,
20
22
One ( u32 ) ,
@@ -149,6 +151,7 @@ fn test_hardcoded_struct_deserialization() {
149
151
option_1 : Option < u8 > ,
150
152
#[ version( start = 3 , end = 4 , default_fn = "default_vec" ) ]
151
153
vec_1 : Vec < char > ,
154
+ #[ allow( clippy:: box_collection) ] // we want to explicitly test Box
152
155
box_1 : Box < String > ,
153
156
#[ version( start = 3 ) ]
154
157
wrapping_1 : Wrapping < u32 > ,
@@ -353,7 +356,7 @@ fn test_hardcoded_enum_deserialization() {
353
356
) ;
354
357
}
355
358
356
- #[ derive( Debug , PartialEq , Versionize ) ]
359
+ #[ derive( Debug , PartialEq , Eq , Versionize ) ]
357
360
pub struct A {
358
361
a : u32 ,
359
362
#[ version( start = 1 , end = 2 ) ]
@@ -362,7 +365,7 @@ pub struct A {
362
365
c : String ,
363
366
}
364
367
365
- #[ derive( Debug , PartialEq , Versionize ) ]
368
+ #[ derive( Debug , PartialEq , Eq , Versionize ) ]
366
369
pub struct X {
367
370
x : bool ,
368
371
a_1 : A ,
@@ -380,7 +383,7 @@ impl A {
380
383
381
384
impl X {
382
385
fn default_y ( _source_version : u16 ) -> Box < usize > {
383
- Box :: from ( 4 as usize )
386
+ Box :: from ( 4 )
384
387
}
385
388
386
389
fn default_z ( _source_version : u16 ) -> Vec < u8 > {
@@ -441,7 +444,7 @@ fn test_nested_structs_deserialization() {
441
444
b : Some ( TestState :: One ( 4 ) ) ,
442
445
c : "some_string" . to_owned ( ) ,
443
446
} ,
444
- y : Box :: from ( 2 as usize ) ,
447
+ y : Box :: from ( 2 ) ,
445
448
z : vec ! [ 16 , 4 ] ,
446
449
} ;
447
450
assert_eq ! ( restored_state, expected_state) ;
@@ -458,7 +461,7 @@ fn test_nested_structs_deserialization() {
458
461
b : None ,
459
462
c : "random" . to_owned ( ) ,
460
463
} ,
461
- y : Box :: from ( 2 as usize ) ,
464
+ y : Box :: from ( 2 ) ,
462
465
z : vec ! [ 16 , 4 ] ,
463
466
} ;
464
467
assert_eq ! ( restored_state, expected_state) ;
@@ -475,7 +478,7 @@ fn test_nested_structs_deserialization() {
475
478
b : None ,
476
479
c : "random" . to_owned ( ) ,
477
480
} ,
478
- y : Box :: from ( 4 as usize ) ,
481
+ y : Box :: from ( 4 ) ,
479
482
z : vec ! [ 24 ; 4 ] ,
480
483
} ;
481
484
assert_eq ! ( restored_state, expected_state) ;
@@ -514,7 +517,7 @@ fn test_versionize_struct_with_array() {
514
517
assert_eq ! ( restored_test_struct, test_struct) ;
515
518
}
516
519
517
- #[ derive( Clone , Debug , PartialEq , Versionize ) ]
520
+ #[ derive( Clone , Debug , PartialEq , Eq , Versionize ) ]
518
521
pub enum DeviceStatus {
519
522
Inactive ,
520
523
Active ,
@@ -528,7 +531,7 @@ impl Default for DeviceStatus {
528
531
}
529
532
}
530
533
531
- #[ derive( Clone , Debug , PartialEq , Versionize ) ]
534
+ #[ derive( Clone , Debug , PartialEq , Eq , Versionize ) ]
532
535
pub enum OperationSupported {
533
536
Add ,
534
537
Remove ,
@@ -567,7 +570,7 @@ impl OperationSupported {
567
570
}
568
571
}
569
572
570
- #[ derive( Clone , Debug , PartialEq , Versionize ) ]
573
+ #[ derive( Clone , Debug , PartialEq , Eq , Versionize ) ]
571
574
pub struct Device {
572
575
name : String ,
573
576
id : Wrapping < u32 > ,
@@ -633,7 +636,7 @@ impl Device {
633
636
assert ! ( target_version < 2 ) ;
634
637
self . some_params . push ( "active" . to_owned ( ) ) ;
635
638
self . some_params
636
- . retain ( |x| x. clone ( ) != "inactive" . to_owned ( ) ) ;
639
+ . retain ( |x| x. clone ( ) != * "inactive" ) ;
637
640
Ok ( ( ) )
638
641
}
639
642
@@ -782,7 +785,7 @@ fn test_versionize_struct_with_enums() {
782
785
) ;
783
786
}
784
787
785
- #[ derive( Clone , Debug , PartialEq , Versionize ) ]
788
+ #[ derive( Clone , Debug , PartialEq , Eq , Versionize ) ]
786
789
pub enum State {
787
790
Zero ,
788
791
One ( bool ) ,
0 commit comments