From 501454370f11401f721586718fdc5d4cd5365c94 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Mon, 10 Jul 2023 12:25:37 +0100 Subject: [PATCH] Fix new "useless_vec" warning from clippy +nightly Explanation at https://rust-lang.github.io/rust-clippy/master/index.html#/useless_vec This is the non-tests subset of the same-named commmit in !1388, (recreated by hand by me, and then checked against that commit; I stole the commit message from Nick's.) This should be uncontroversial I think. --- crates/tor-linkspec/src/ids.rs | 2 +- crates/tor-rtcompat/src/lib.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/tor-linkspec/src/ids.rs b/crates/tor-linkspec/src/ids.rs index b2514817b..62e8ab870 100644 --- a/crates/tor-linkspec/src/ids.rs +++ b/crates/tor-linkspec/src/ids.rs @@ -280,7 +280,7 @@ impl std::str::FromStr for RelayId { let bytes = hex::decode(s).map_err(|_| RelayIdError::BadHex)?; RelayId::from_type_and_bytes(RelayIdType::Rsa, &bytes) } else { - let mut v = vec![0_u8; ED25519_ID_LEN]; + let mut v = [0_u8; ED25519_ID_LEN]; let bytes = Base64Unpadded::decode(s, &mut v[..])?; RelayId::from_type_and_bytes(RelayIdType::Ed25519, bytes) } diff --git a/crates/tor-rtcompat/src/lib.rs b/crates/tor-rtcompat/src/lib.rs index 08f6d9e06..dbda829a4 100644 --- a/crates/tor-rtcompat/src/lib.rs +++ b/crates/tor-rtcompat/src/lib.rs @@ -455,7 +455,7 @@ mod test { runtime.block_on(async { let task1 = async { - let mut buf = vec![0_u8; 16]; + let mut buf = [0_u8; 16]; let (len, addr) = socket1.recv(&mut buf[..]).await?; IoResult::Ok((buf[..len].to_vec(), addr)) }; @@ -491,7 +491,7 @@ mod test { let mut n = 0_u32; loop { let (mut con, _addr) = stream.next().await.unwrap()?; - let mut buf = vec![0_u8; 11]; + let mut buf = [0_u8; 11]; con.read_exact(&mut buf[..]).await?; n += 1; if &buf[..] == b"world done!" {