summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNadrieril2020-11-01 19:03:21 +0000
committerNadrieril2020-11-01 19:03:21 +0000
commit34d92560a0a2124e5eadea4832795874505b6cc5 (patch)
tree9a073edefe72ea115167ddbb876d34ac581d9450
parent8cfb6d563d26abb2fa80124eda2231eb05c7f3e6 (diff)
fix: clippy
-rw-r--r--dhall/src/semantics/resolve/cache.rs8
-rw-r--r--dhall/src/semantics/resolve/resolve.rs31
2 files changed, 18 insertions, 21 deletions
diff --git a/dhall/src/semantics/resolve/cache.rs b/dhall/src/semantics/resolve/cache.rs
index 7763f18..b00a2d5 100644
--- a/dhall/src/semantics/resolve/cache.rs
+++ b/dhall/src/semantics/resolve/cache.rs
@@ -55,11 +55,9 @@ impl Cache {
pub fn get(&self, hash: &Hash) -> Result<Typed, Error> {
let path = self.entry_path(hash);
let res = read_cache_file(&path, hash);
- if let Err(_) = res {
- if path.exists() {
- // Delete cache file since it's invalid. We ignore the error.
- let _ = std::fs::remove_file(&path);
- }
+ if res.is_err() && path.exists() {
+ // Delete cache file since it's invalid. We ignore the error.
+ let _ = std::fs::remove_file(&path);
}
res
}
diff --git a/dhall/src/semantics/resolve/resolve.rs b/dhall/src/semantics/resolve/resolve.rs
index 68b899c..572df25 100644
--- a/dhall/src/semantics/resolve/resolve.rs
+++ b/dhall/src/semantics/resolve/resolve.rs
@@ -218,23 +218,22 @@ fn make_aslocation_uniontype() -> Expr {
}
fn check_hash(import: &Import, typed: &Typed, span: Span) -> Result<(), Error> {
- match (import.mode, &import.hash) {
- (ImportMode::Code, Some(Hash::SHA256(hash))) => {
- let actual_hash = typed.hir.to_expr_alpha().sha256_hash()?;
- if hash[..] != actual_hash[..] {
- mkerr(
- ErrorBuilder::new("hash mismatch")
- .span_err(span, "hash mismatch")
- .note(format!("Expected sha256:{}", hex::encode(hash)))
- .note(format!(
- "Found sha256:{}",
- hex::encode(actual_hash)
- ))
- .format(),
- )?
- }
+ if let (ImportMode::Code, Some(Hash::SHA256(hash))) =
+ (import.mode, &import.hash)
+ {
+ let actual_hash = typed.hir.to_expr_alpha().sha256_hash()?;
+ if hash[..] != actual_hash[..] {
+ mkerr(
+ ErrorBuilder::new("hash mismatch")
+ .span_err(span, "hash mismatch")
+ .note(format!("Expected sha256:{}", hex::encode(hash)))
+ .note(format!(
+ "Found sha256:{}",
+ hex::encode(actual_hash)
+ ))
+ .format(),
+ )?
}
- _ => {}
}
Ok(())
}