Skip to content

Commit 6da8334

Browse files
committed
chore: fix clippy warning on latest stable
There are additional clippy warning on Rust 1.51. This commit fixes those.
1 parent 5f4398e commit 6da8334

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

derive/src/multihash.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -131,21 +131,21 @@ impl<'a> From<&'a VariantInfo<'a>> for Hash {
131131
let code = code.unwrap_or_else(|| {
132132
let msg = "Missing code attribute: e.g. #[mh(code = multihash::SHA3_256)]";
133133
#[cfg(test)]
134-
panic!(msg);
134+
panic!("{}", msg);
135135
#[cfg(not(test))]
136136
proc_macro_error::abort!(ident, msg);
137137
});
138138
let hasher = hasher.unwrap_or_else(|| {
139139
let msg = "Missing hasher attribute: e.g. #[mh(hasher = multihash::Sha2_256)]";
140140
#[cfg(test)]
141-
panic!(msg);
141+
panic!("{}", msg);
142142
#[cfg(not(test))]
143143
proc_macro_error::abort!(ident, msg);
144144
});
145145
let digest = digest.unwrap_or_else(|| {
146146
let msg = "Missing digest atttibute: e.g. #[mh(digest = multihash::Sha2Digest<U32>)]";
147147
#[cfg(test)]
148-
panic!(msg);
148+
panic!("{}", msg);
149149
#[cfg(not(test))]
150150
proc_macro_error::abort!(ident, msg);
151151
});
@@ -183,7 +183,7 @@ fn parse_code_enum_attrs(ast: &syn::DeriveInput) -> (syn::Type, bool) {
183183
None => {
184184
let msg = "enum is missing `alloc_size` attribute: e.g. #[mh(alloc_size = U64)]";
185185
#[cfg(test)]
186-
panic!(msg);
186+
panic!("{}", msg);
187187
#[cfg(not(test))]
188188
proc_macro_error::abort!(&ast.ident, msg);
189189
}
@@ -208,7 +208,7 @@ fn error_code_duplicates(hashes: &[Hash]) {
208208
// It's a duplicate
209209
if !uniq.insert(code) {
210210
#[cfg(test)]
211-
panic!(msg);
211+
panic!("{}", msg);
212212
#[cfg(not(test))]
213213
{
214214
let already_defined = uniq.get(code).unwrap();
@@ -254,7 +254,7 @@ fn parse_alloc_size_attribute(alloc_size: &syn::Type) -> u64 {
254254
parse_unsigned_typenum(&alloc_size).unwrap_or_else(|_| {
255255
let msg = "`alloc_size` attribute must be a `typenum`, e.g. #[mh(alloc_size = U64)]";
256256
#[cfg(test)]
257-
panic!(msg);
257+
panic!("{}", msg);
258258
#[cfg(not(test))]
259259
proc_macro_error::abort!(&alloc_size, msg);
260260
})
@@ -278,7 +278,7 @@ fn error_alloc_size(hashes: &[Hash], expected_alloc_size_type: &syn::Type) {
278278
let msg = format!("The `#mh(alloc_size) attribute must be bigger than the maximum defined digest size (U{})",
279279
max_digest_size);
280280
#[cfg(test)]
281-
panic!(msg);
281+
panic!("{}", msg);
282282
#[cfg(not(test))]
283283
{
284284
let digest = &hash.digest.to_token_stream().to_string().replace(" ", "");
@@ -305,7 +305,7 @@ fn error_alloc_size(hashes: &[Hash], expected_alloc_size_type: &syn::Type) {
305305
if let Err(_error) = maybe_error {
306306
let msg = "Invalid byte size. It must be a unsigned integer typenum, e.g. `U32`";
307307
#[cfg(test)]
308-
panic!(msg);
308+
panic!("{}", msg);
309309
#[cfg(not(test))]
310310
{
311311
proc_macro_error::emit_error!(&_error.0, msg);

src/multihash_impl.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ mod tests {
9191
let hash2 = Code::Sha3_256.digest(b"hello world");
9292
assert_eq!(hash.code(), u64::from(Code::Sha3_256));
9393
assert_eq!(hash.size(), 32);
94-
assert_eq!(hash.digest(), &digest.as_ref()[..]);
94+
assert_eq!(hash.digest(), digest.as_ref());
9595
assert_eq!(hash, hash2);
9696
}
9797

@@ -102,7 +102,7 @@ mod tests {
102102
let hash2 = Code::Sha3_512.digest(b"hello world");
103103
assert_eq!(hash.code(), u64::from(Code::Sha3_512));
104104
assert_eq!(hash.size(), 64);
105-
assert_eq!(hash.digest(), &digest.as_ref()[..]);
105+
assert_eq!(hash.digest(), digest.as_ref());
106106
assert_eq!(hash, hash2);
107107
}
108108
}

0 commit comments

Comments
 (0)