Skip to content

Commit 155a267

Browse files
oslfmtsmoelius
authored andcommitted
clean up lint messages
1 parent 117b54d commit 155a267

File tree

5 files changed

+16
-15
lines changed

5 files changed

+16
-15
lines changed

lints/type_cosplay/src/lib.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ impl<'tcx> LateLintPass<'tcx> for TypeCosplay {
113113
spans[0],
114114
"Deserializing from different ADT types.",
115115
Some(spans[1]),
116-
"help: deserialize from only structs with a discriminant, or an enum encapsulating all structs."
116+
"deserialize from only structs with a discriminant, or an enum encapsulating all structs."
117117
);
118118
}
119119
}
@@ -150,9 +150,9 @@ fn check_enums(cx: &LateContext<'_>, enums: &Vec<(DefId, Span)>) {
150150
cx,
151151
TYPE_COSPLAY,
152152
first_span,
153-
"warning: multiple enum types deserialized. Should only have one enum type to avoid possible equivalent types",
153+
"multiple enum types deserialized. Should only have one enum type to avoid possible equivalent types",
154154
Some(second_span),
155-
"help: consider constructing a single enum that contains all type definitions as variants"
155+
"consider constructing a single enum that contains all type definitions as variants"
156156
);
157157
} else if enums.len() == 1 {
158158
// future check - check that single enum is safe
@@ -185,16 +185,16 @@ fn has_discriminant(cx: &LateContext, adt: AdtDef, num_struct_types: usize, span
185185
cx,
186186
TYPE_COSPLAY,
187187
span,
188-
"warning: type does not have a proper discriminant. It may be indistinguishable when deserialized.",
188+
"type does not have a proper discriminant. It may be indistinguishable when deserialized.",
189189
None,
190-
"help: add an enum with at least as many variants as there are struct definitions"
190+
"add an enum with at least as many variants as there are struct definitions"
191191
)
192192
}
193193
}
194194
}
195195

196196
#[test]
197-
fn insecure_1() {
197+
fn insecure() {
198198
dylint_testing::ui_test_example(env!("CARGO_PKG_NAME"), "insecure");
199199
}
200200

lints/type_cosplay/ui/insecure-2/src/lib.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
error: warning: multiple enum types deserialized. Should only have one enum type to avoid possible equivalent types
1+
error: multiple enum types deserialized. Should only have one enum type to avoid possible equivalent types
22
--> $DIR/lib.rs:27:20
33
|
44
LL | let user = UserInfo::try_from_slice(&ctx.accounts.user.data.borrow()).unwrap();
55
| ^^^^^^^^
66
|
77
= note: `-D type-cosplay` implied by `-D warnings`
8-
help: help: consider constructing a single enum that contains all type definitions as variants
8+
help: consider constructing a single enum that contains all type definitions as variants
99
--> $DIR/lib.rs:41:24
1010
|
1111
LL | let metadata = MetadataInfo::try_from_slice(&ctx.accounts.user.data.borrow()).unwrap();

lints/type_cosplay/ui/insecure-3/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ pub mod type_cosplay_secure {
2525
}
2626
msg!("GM {}", user.authority);
2727

28-
let extra = Instruction::try_from_slice(&ctx.accounts.user.data.borrow()).unwrap();
28+
let _extra =
29+
AccountWithDiscriminant::try_from_slice(&ctx.accounts.user.data.borrow()).unwrap();
2930
Ok(())
3031
}
3132
}

lints/type_cosplay/ui/insecure-3/src/lib.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ LL | let user = User::try_from_slice(&ctx.accounts.user.data.borrow()).u
55
| ^^^^
66
|
77
= note: `-D type-cosplay` implied by `-D warnings`
8-
help: help: deserialize from only structs with a discriminant, or an enum encapsulating all structs.
9-
--> $DIR/lib.rs:28:21
8+
help: deserialize from only structs with a discriminant, or an enum encapsulating all structs.
9+
--> $DIR/lib.rs:29:13
1010
|
11-
LL | let extra = Instruction::try_from_slice(&ctx.accounts.user.data.borrow()).unwrap();
12-
| ^^^^^^^^^^^
11+
LL | AccountWithDiscriminant::try_from_slice(&ctx.accounts.user.data.borrow()).unwrap();
12+
| ^^^^^^^^^^^^^^^^^^^^^^^
1313

1414
error: aborting due to previous error
1515

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
error: warning: type does not have a proper discriminant. It may be indistinguishable when deserialized.
1+
error: type does not have a proper discriminant. It may be indistinguishable when deserialized.
22
--> $DIR/lib.rs:13:20
33
|
44
LL | let user = User::try_from_slice(&ctx.accounts.user.data.borrow()).unwrap();
55
| ^^^^
66
|
77
= note: `-D type-cosplay` implied by `-D warnings`
8-
= help: help: add an enum with at least as many variants as there are struct definitions
8+
= help: add an enum with at least as many variants as there are struct definitions
99

1010
error: aborting due to previous error
1111

0 commit comments

Comments
 (0)