Skip to content

Commit fc2d733

Browse files
committed
Remove Deref impl for Checksum
1 parent 914006e commit fc2d733

File tree

2 files changed

+3
-22
lines changed

2 files changed

+3
-22
lines changed

contracts/virus/src/contract.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,9 @@ pub fn execute_spread(
6060

6161
attributes.push(Attribute::new(format!("path{i}"), path.clone()));
6262

63-
// clippy produces a false positive here, see https://github.com/rust-lang/rust-clippy/issues/9841
64-
#[allow(clippy::explicit_auto_deref)]
65-
let address = deps
66-
.api
67-
.addr_humanize(&instantiate2_address(&*checksum, &creator, &salt)?)?;
63+
let address =
64+
deps.api
65+
.addr_humanize(&instantiate2_address(checksum.as_ref(), &creator, &salt)?)?;
6866
attributes.push(Attribute::new(
6967
format!("predicted_address{i}"),
7068
address.clone(),

packages/std/src/checksum.rs

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use core::fmt;
2-
use core::ops::Deref;
32

43
use schemars::JsonSchema;
54
use serde::{de, ser, Deserialize, Deserializer, Serialize};
@@ -53,19 +52,6 @@ impl From<[u8; 32]> for Checksum {
5352
}
5453
}
5554

56-
/// Just like Vec<u8>, Checksum is a smart pointer to [u8].
57-
/// This implements `*data` for us and allows us to
58-
/// do `&*data`, returning a `&[u8]` from a `&Checksum`.
59-
/// With [deref coercions](https://doc.rust-lang.org/1.22.1/book/first-edition/deref-coercions.html#deref-coercions),
60-
/// this allows us to use `&data` whenever a `&[u8]` is required.
61-
impl Deref for Checksum {
62-
type Target = [u8; 32];
63-
64-
fn deref(&self) -> &Self::Target {
65-
self.as_ref()
66-
}
67-
}
68-
6955
impl AsRef<[u8; 32]> for Checksum {
7056
fn as_ref(&self) -> &[u8; 32] {
7157
&self.0
@@ -210,9 +196,6 @@ mod tests {
210196
#[test]
211197
fn ref_conversions_work() {
212198
let checksum = Checksum::generate(&[12u8; 17]);
213-
// deref
214-
let _: &[u8; 32] = &checksum;
215-
let _: &[u8] = &*checksum;
216199
// as_ref
217200
let _: &[u8; 32] = checksum.as_ref();
218201
let _: &[u8] = checksum.as_ref();

0 commit comments

Comments
 (0)