Skip to content

Commit bc99052

Browse files
committed
chore: address clippy warnings
Signed-off-by: Roman Volosatovs <[email protected]>
1 parent 479fada commit bc99052

File tree

3 files changed

+14
-18
lines changed

3 files changed

+14
-18
lines changed

crates/wit-deps/src/cache.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ use url::{Host, Url};
1515
/// Resource caching layer
1616
#[async_trait]
1717
pub trait Cache {
18-
/// Type returned by the [Self::get] method
18+
/// Type returned by the [`Self::get`] method
1919
type Read: AsyncBufRead + Unpin;
20-
/// Type returned by the [Self::insert] method
20+
/// Type returned by the [`Self::insert`] method
2121
type Write: AsyncWrite + Unpin;
2222

2323
/// Returns a read handle for the entry from the cache associated with a given URL

crates/wit-deps/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ async fn recreate_dir(path: impl AsRef<Path>) -> std::io::Result<()> {
6161
Ok(()) => {}
6262
Err(e) if e.kind() == std::io::ErrorKind::NotFound => {}
6363
Err(e) => return Err(e),
64-
};
64+
}
6565
fs::create_dir_all(path)
6666
.await
6767
.map(|()| trace!("recreated `{}`", path.display()))
@@ -181,7 +181,7 @@ async fn copy_wits(
181181
}
182182

183183
/// Unpacks all WIT interfaces found within `wit` subtree of a tar archive read from `tar` to
184-
/// `dst` and returns a [HashMap] of all unpacked transitive dependency identifiers.
184+
/// `dst` and returns a [`HashMap`] of all unpacked transitive dependency identifiers.
185185
///
186186
/// # Errors
187187
///

crates/wit-deps/src/manifest.rs

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,8 @@ fn source_matches(
182182
sha512: Option<[u8; 64]>,
183183
) -> bool {
184184
let digest = digest.into();
185-
sha256.map_or(true, |sha256| sha256 == digest.sha256)
186-
&& sha512.map_or(true, |sha512| sha512 == digest.sha512)
185+
sha256.is_none_or(|sha256| sha256 == digest.sha256)
186+
&& sha512.is_none_or(|sha512| sha512 == digest.sha512)
187187
}
188188

189189
#[instrument(level = "trace", skip(deps))]
@@ -382,11 +382,7 @@ impl Entry {
382382
}
383383
}
384384
}
385-
if let Ok(cache) = cache.insert(&url).await {
386-
Some(cache)
387-
} else {
388-
None
389-
}
385+
cache.insert(&url).await.ok()
390386
} else {
391387
None
392388
};
@@ -400,13 +396,13 @@ impl Entry {
400396
.send()
401397
.await
402398
.context("failed to GET")
403-
.map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e))?
399+
.map_err(std::io::Error::other)?
404400
.error_for_status()
405401
.context("GET request failed")
406-
.map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e))?;
402+
.map_err(std::io::Error::other)?;
407403
let tar_gz = res
408404
.bytes_stream()
409-
.map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e))
405+
.map_err(std::io::Error::other)
410406
.then(|chunk| async {
411407
let chunk = chunk?;
412408
let mut cache = cache.lock().await;
@@ -464,9 +460,9 @@ path = "/path/to/my/dep"
464460
if digest.sha256 != sha256 {
465461
remove_dir_all(out).await?;
466462
bail!(
467-
r#"sha256 hash mismatch for `{url}`
463+
r"sha256 hash mismatch for `{url}`
468464
got: {}
469-
expected: {}"#,
465+
expected: {}",
470466
hex::encode(digest.sha256),
471467
hex::encode(sha256),
472468
);
@@ -476,9 +472,9 @@ expected: {}"#,
476472
if digest.sha512 != sha512 {
477473
remove_dir_all(out).await?;
478474
bail!(
479-
r#"sha512 hash mismatch for `{url}`
475+
r"sha512 hash mismatch for `{url}`
480476
got: {}
481-
expected: {}"#,
477+
expected: {}",
482478
hex::encode(digest.sha512),
483479
hex::encode(sha512),
484480
);

0 commit comments

Comments
 (0)