File tree Expand file tree Collapse file tree 2 files changed +4
-3
lines changed Expand file tree Collapse file tree 2 files changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -77,13 +77,14 @@ impl<'tcx> LateLintPass<'tcx> for TypeCosplay {
77
77
}
78
78
79
79
fn check_crate_post ( & mut self , cx : & LateContext < ' tcx > ) {
80
+ // NOTE: the case where len == 0 does nothing, since no types are deserialized
80
81
if self . deser_types . len ( ) == 1 {
81
82
let ( k, v) = self . deser_types . iter ( ) . next ( ) . unwrap ( ) ;
82
83
match k {
83
84
AdtKind :: Enum => check_enums ( cx, v) ,
84
85
_ => check_structs_have_discriminant ( cx, v) , // NOTE: also catches unions
85
86
}
86
- } else {
87
+ } else if self . deser_types . len ( ) > 1 {
87
88
// Retrieve spans: iter through map, grab first elem of each key-pair, then get span
88
89
let mut spans = vec ! [ ] ;
89
90
self . deser_types . iter ( ) . for_each ( |( _, v) | {
Original file line number Diff line number Diff line change @@ -8,8 +8,8 @@ LL | let user = User::try_from_slice(&ctx.accounts.user.data.borrow()).u
8
8
help: help: deserialize from only structs with a discriminant, or an enum encapsulating all structs.
9
9
--> $DIR/lib.rs:28:21
10
10
|
11
- LL | let extra = AnotherDiscriminant ::try_from_slice(&ctx.accounts.user.data.borrow()).unwrap();
12
- | ^^^^^^^^^^^^^^^^^^^
11
+ LL | let extra = Instruction ::try_from_slice(&ctx.accounts.user.data.borrow()).unwrap();
12
+ | ^^^^^^^^^^^
13
13
14
14
error: aborting due to previous error
15
15
You can’t perform that action at this time.
0 commit comments