fix clippy::needless_borrow
This commit is contained in:
parent
dcbdd076eb
commit
8e7a904260
|
@ -530,6 +530,8 @@ mod test {
|
|||
let sa4: SocketAddrV4 = "203.0.133.8:81".parse().unwrap();
|
||||
let sa6: SocketAddrV6 = "[2001:db8::43]:82".parse().unwrap();
|
||||
|
||||
// TODO do we want to keep that bit of test, or should we remove it?
|
||||
#[allow(clippy::needless_borrow)]
|
||||
check(&(ip, 443), "203.0.133.6:443");
|
||||
check((ip, 443), "203.0.133.6:443");
|
||||
check((ip4, 444), "203.0.133.7:444");
|
||||
|
|
|
@ -445,7 +445,7 @@ mod test {
|
|||
// Try resolving a simple path that exists.
|
||||
d.file("a/b/c");
|
||||
let mut r = ResolvePath::new(d.path("a/b/c")).unwrap();
|
||||
skip_past(&mut r, &root);
|
||||
skip_past(&mut r, root);
|
||||
let mut so_far = root.to_path_buf();
|
||||
for (c, p) in Path::new("a/b/c").components().zip(&mut r) {
|
||||
let (p, pt, meta) = p.unwrap();
|
||||
|
@ -465,7 +465,7 @@ mod test {
|
|||
|
||||
// Same as above, starting from a relative path to the target.
|
||||
let mut r = ResolvePath::new(d.relative_root().join("a/b/c")).unwrap();
|
||||
skip_past(&mut r, &root);
|
||||
skip_past(&mut r, root);
|
||||
let mut so_far = root.to_path_buf();
|
||||
for (c, p) in Path::new("a/b/c").components().zip(&mut r) {
|
||||
let (p, pt, meta) = p.unwrap();
|
||||
|
@ -486,7 +486,7 @@ mod test {
|
|||
|
||||
// Try resolving a simple path that doesn't exist.
|
||||
let mut r = ResolvePath::new(d.path("a/xxx/yyy")).unwrap();
|
||||
skip_past(&mut r, &root);
|
||||
skip_past(&mut r, root);
|
||||
let (p, pt, _) = r.next().unwrap().unwrap();
|
||||
assert_eq!(p, root.join("a"));
|
||||
assert_eq!(pt, PathType::Intermediate);
|
||||
|
@ -510,7 +510,7 @@ mod test {
|
|||
// get each given path once.
|
||||
d.dir("a/b/c/d");
|
||||
let mut r = ResolvePath::new(root.join("a/b/../b/../b/c/../c/d")).unwrap();
|
||||
skip_past(&mut r, &root);
|
||||
skip_past(&mut r, root);
|
||||
let paths: Vec<_> = r.map(|item| item.unwrap().0).collect();
|
||||
assert_eq!(
|
||||
paths,
|
||||
|
@ -526,7 +526,7 @@ mod test {
|
|||
// each path once.
|
||||
d.link_rel(LinkType::Dir, "../../", "a/b/c/rel_lnk");
|
||||
let mut r = ResolvePath::new(root.join("a/b/c/rel_lnk/b/c/d")).unwrap();
|
||||
skip_past(&mut r, &root);
|
||||
skip_past(&mut r, root);
|
||||
let paths: Vec<_> = r.map(|item| item.unwrap().0).collect();
|
||||
assert_eq!(
|
||||
paths,
|
||||
|
@ -542,7 +542,7 @@ mod test {
|
|||
// Once more, with an absolute symlink.
|
||||
d.link_abs(LinkType::Dir, "a", "a/b/c/abs_lnk");
|
||||
let mut r = ResolvePath::new(root.join("a/b/c/abs_lnk/b/c/d")).unwrap();
|
||||
skip_past(&mut r, &root);
|
||||
skip_past(&mut r, root);
|
||||
let paths: Vec<_> = r.map(|item| item.unwrap().0).collect();
|
||||
assert_eq!(
|
||||
paths,
|
||||
|
@ -557,7 +557,7 @@ mod test {
|
|||
|
||||
// One more, with multiple links.
|
||||
let mut r = ResolvePath::new(root.join("a/b/c/abs_lnk/b/c/rel_lnk/b/c/d")).unwrap();
|
||||
skip_past(&mut r, &root);
|
||||
skip_past(&mut r, root);
|
||||
let paths: Vec<_> = r.map(|item| item.unwrap().0).collect();
|
||||
assert_eq!(
|
||||
paths,
|
||||
|
@ -575,7 +575,7 @@ mod test {
|
|||
let mut r =
|
||||
ResolvePath::new(root.join("a/b/c/abs_lnk/b/c/rel_lnk/b/c/rel_lnk/b/c/abs_lnk/b/c/d"))
|
||||
.unwrap();
|
||||
skip_past(&mut r, &root);
|
||||
skip_past(&mut r, root);
|
||||
let paths: Vec<_> = r.map(|item| item.unwrap().0).collect();
|
||||
assert_eq!(
|
||||
paths,
|
||||
|
@ -600,7 +600,7 @@ mod test {
|
|||
// This file links to itself. We should hit our loop detector and barf.
|
||||
d.link_rel(LinkType::File, "../../b/c/d", "a/b/c/d");
|
||||
let mut r = ResolvePath::new(root.join("a/b/c/d")).unwrap();
|
||||
skip_past(&mut r, &root);
|
||||
skip_past(&mut r, root);
|
||||
assert_eq!(r.next().unwrap().unwrap().0, root.join("a"));
|
||||
assert_eq!(r.next().unwrap().unwrap().0, root.join("a/b"));
|
||||
assert_eq!(r.next().unwrap().unwrap().0, root.join("a/b/c"));
|
||||
|
@ -615,7 +615,7 @@ mod test {
|
|||
d.link_rel(LinkType::Dir, "./f", "a/b/c/e");
|
||||
d.link_rel(LinkType::Dir, "./e", "a/b/c/f");
|
||||
let mut r = ResolvePath::new(root.join("a/b/c/e/413")).unwrap();
|
||||
skip_past(&mut r, &root);
|
||||
skip_past(&mut r, root);
|
||||
assert_eq!(r.next().unwrap().unwrap().0, root.join("a"));
|
||||
assert_eq!(r.next().unwrap().unwrap().0, root.join("a/b"));
|
||||
assert_eq!(r.next().unwrap().unwrap().0, root.join("a/b/c"));
|
||||
|
@ -642,16 +642,13 @@ mod test {
|
|||
d.chmod("a/b/c/d", 0o000);
|
||||
|
||||
let mut r = ResolvePath::new(root.join("a/b/c/d/e/413")).unwrap();
|
||||
skip_past(&mut r, &root);
|
||||
skip_past(&mut r, root);
|
||||
let resolvable: Vec<_> = (&mut r)
|
||||
.take(4)
|
||||
.map(|item| {
|
||||
let (p, _, m) = item.unwrap();
|
||||
(
|
||||
p.strip_prefix(&root)
|
||||
.unwrap()
|
||||
.to_string_lossy()
|
||||
.into_owned(),
|
||||
p.strip_prefix(root).unwrap().to_string_lossy().into_owned(),
|
||||
m.permissions().mode() & 0o777,
|
||||
)
|
||||
})
|
||||
|
|
|
@ -250,7 +250,7 @@ mod test {
|
|||
}
|
||||
{
|
||||
let seed = *b"hello world. this is a longer st";
|
||||
let mut s = hex::encode(&seed);
|
||||
let mut s = hex::encode(seed);
|
||||
assert_eq!(Ok(Config::Seeded(seed)), Config::from_str(&s));
|
||||
// we can make it longer, and it just gets truncated.
|
||||
s.push_str("aabbccddeeff");
|
||||
|
|
|
@ -255,7 +255,7 @@ impl ConfigurationSources {
|
|||
use ConfigurationSource as CS;
|
||||
match &source {
|
||||
CS::Dir(found) => {
|
||||
let dir = match fs::read_dir(&found) {
|
||||
let dir = match fs::read_dir(found) {
|
||||
Ok(y) => y,
|
||||
Err(e) => {
|
||||
handle_io_error(e)?;
|
||||
|
|
|
@ -422,7 +422,7 @@ impl Store for SqliteStore {
|
|||
valid_until,
|
||||
flavor.name(),
|
||||
pending,
|
||||
hex::encode(&sha3_of_signed),
|
||||
hex::encode(sha3_of_signed),
|
||||
h.digeststr
|
||||
],
|
||||
)?;
|
||||
|
|
|
@ -352,19 +352,19 @@ fn tv_sha3_256() {
|
|||
&hex!("a7ffc6f8bf1ed76651c14756a061d662f580ff4de43b49fa82d80a4b80f8434a")
|
||||
);
|
||||
|
||||
let d = ll::d::Sha3_256::digest(&hex!("e9"));
|
||||
let d = ll::d::Sha3_256::digest(hex!("e9"));
|
||||
assert_eq!(
|
||||
&d[..],
|
||||
&hex!("f0d04dd1e6cfc29a4460d521796852f25d9ef8d28b44ee91ff5b759d72c1e6d6")
|
||||
);
|
||||
|
||||
let d = ll::d::Sha3_256::digest(&hex!("d16d978dfbaecf2c8a04090f6eebdb421a5a711137a6"));
|
||||
let d = ll::d::Sha3_256::digest(hex!("d16d978dfbaecf2c8a04090f6eebdb421a5a711137a6"));
|
||||
assert_eq!(
|
||||
&d[..],
|
||||
&hex!("7f497913318defdc60c924b3704b65ada7ca3ba203f23fb918c6fb03d4b0c0da")
|
||||
);
|
||||
|
||||
let d = ll::d::Sha3_256::digest(&hex!(
|
||||
let d = ll::d::Sha3_256::digest(hex!(
|
||||
"3341ca020d4835838b0d6c8f93aaaebb7af60730d208c85283f6369f1ee27fd96d38f2674f
|
||||
316ef9c29c1b6b42dd59ec5236f65f5845a401adceaa4cf5bbd91cac61c21102052634e99faedd6c
|
||||
dddcd4426b42b6a372f29a5a5f35f51ce580bb1845a3c7cfcd447d269e8caeb9b320bb731f53fe5c
|
||||
|
|
|
@ -178,7 +178,7 @@ where
|
|||
};
|
||||
// everybody is family with the adjacent relay.
|
||||
let fam_id = [idx ^ 1; 20];
|
||||
let family = hex::encode(&fam_id);
|
||||
let family = hex::encode(fam_id);
|
||||
|
||||
let mut md_builder = Microdesc::builder();
|
||||
md_builder
|
||||
|
|
|
@ -71,7 +71,7 @@ impl Kdf for LegacyKdf {
|
|||
while result.len() < n_bytes {
|
||||
let mut d = Sha1::new();
|
||||
Digest::update(&mut d, seed);
|
||||
Digest::update(&mut d, &[k]);
|
||||
Digest::update(&mut d, [k]);
|
||||
d.finalize_into(&mut digest_output);
|
||||
result.extend_from_slice(&digest_output);
|
||||
k += 1;
|
||||
|
|
Loading…
Reference in New Issue