diff --git a/src/checkers/history/mod.rs b/src/checkers/history/mod.rs index ade9b8d..a437f12 100644 --- a/src/checkers/history/mod.rs +++ b/src/checkers/history/mod.rs @@ -82,6 +82,7 @@ async fn get_history_dirs_not_for_id(id: &Uuid) -> Result, io::Er /// /// Any I/O unexpected errors that may occur while reading and/or /// writing the UUID file. +#[allow(clippy::missing_panics_doc)] pub async fn get_or_generate_uuid() -> Result { let uuid_file = get_uuid_file(); let _span = tracing::debug_span!("get_or_generate_uuid", file = ?uuid_file); diff --git a/src/checkers/history/operation/util.rs b/src/checkers/history/operation/util.rs index 3d7abd6..c35af31 100644 --- a/src/checkers/history/operation/util.rs +++ b/src/checkers/history/operation/util.rs @@ -173,6 +173,10 @@ pub(crate) async fn cleanup_operations() -> Result { // Get hoard history root // Iterate over every uuid in the directory let root = get_history_root_dir(); + + // The .fold() at the end creates a new error based on the old one, which + // is not compatible with try_fold() + #[allow(clippy::manual_try_fold)] fs::read_dir(&root) .await .map(ReadDirStream::new) diff --git a/src/config/builder/environment/mod.rs b/src/config/builder/environment/mod.rs index d38d219..385ef71 100644 --- a/src/config/builder/environment/mod.rs +++ b/src/config/builder/environment/mod.rs @@ -225,7 +225,7 @@ mod tests { path_exists: Some(Combinator(vec![Inner::Single(path_exists.clone())])), }; - let expected = vec![ + let expected = [ format!("({hostname})"), format!("({os})"), format!("({env_var})"), diff --git a/src/config/builder/envtrie.rs b/src/config/builder/envtrie.rs index 036df9f..28cb1c5 100644 --- a/src/config/builder/envtrie.rs +++ b/src/config/builder/envtrie.rs @@ -272,7 +272,7 @@ fn get_weighted_map( // Check for cycles, then discard graph tracing::trace!("checking for cycles"); let mut score_dag = DiGraph::::new(); - for list in exclusive_list.iter() { + for list in exclusive_list { let mut prev_idx = None; for name in list.iter().rev() { @@ -433,22 +433,17 @@ impl EnvTrie { let tree = nodes .into_iter() - .fold(Ok(BTreeMap::::new()), |acc, node| { + .try_fold(BTreeMap::::new(), |mut acc, node| { // TODO: Use result flattening when stable - match acc { - Err(err) => Err(err), - Ok(mut tree) => { - // Explicitly call `drop()` to drop any old value. - match tree.remove(&node.name) { - None => drop(tree.insert(node.name.clone(), node)), - Some(existing) => { - let new_node = existing.merge_with(node)?; - drop(tree.insert(new_node.name.clone(), new_node)); - } - } - Ok(tree) + // Explicitly call `drop()` to drop any old value. + match acc.remove(&node.name) { + None => drop(acc.insert(node.name.clone(), node)), + Some(existing) => { + let new_node = existing.merge_with(node)?; + drop(acc.insert(new_node.name.clone(), new_node)); } } + Ok(acc) })?; Ok(EnvTrie(tree)) } @@ -476,10 +471,9 @@ impl EnvTrie { .transpose() .map(|path| (env, node, path)) }) - .fold(Ok(None), |acc, (_, node, path)| match (acc, path) { - (Err(err), _) | (_, Err(err)) => Err(err), - (Ok(None), Ok(path)) => Ok(Some((node, path))), - (Ok(Some((acc, acc_path))), Ok(path)) => match acc.score.cmp(&node.score) { + .try_fold(None, |acc: Option<(&Node, _)>, (_, node, path)| match (acc, path) { + (None, path) => Ok(Some((node, path))), + (Some((acc, acc_path)), path) => match acc.score.cmp(&node.score) { Ordering::Equal => Err(Error::Indecision( acc.name.clone().into(), node.name.clone().into(), @@ -489,7 +483,6 @@ impl EnvTrie { }, })? .map(|(_, path)| path) - .map(Ok) .transpose() } } @@ -549,7 +542,7 @@ mod tests { return false; } - for (key, node1) in tree1.iter() { + for (key, node1) in tree1 { let equal = match tree2.get(key) { None => false, Some(node2) => node_eq_ignore_score(node1, node2), diff --git a/src/env_vars.rs b/src/env_vars.rs index f3c6ebb..c0f8ab5 100644 --- a/src/env_vars.rs +++ b/src/env_vars.rs @@ -12,7 +12,7 @@ use std::{env, fmt}; // // The `+?` is non-greedy matching, which is necessary for if there are multiple variables. static ENV_REGEX: Lazy = Lazy::new(|| { - Regex::new(r#"\$\{[^(=|\x{0}|$)]+?}"#).expect("failed to compile regular expression") + Regex::new(r"\$\{[^(=|\x{0}|$)]+?}").expect("failed to compile regular expression") }); /// An error that may occur during expansion. diff --git a/src/paths.rs b/src/paths.rs index 2f469a1..8411234 100644 --- a/src/paths.rs +++ b/src/paths.rs @@ -168,6 +168,7 @@ impl HoardPath { /// use it as the prefix directory for a [`RelativePath`]. It is up to the caller to make /// sure the resulting path is valid for use. #[must_use] + #[allow(clippy::missing_panics_doc)] pub fn join(&self, rhs: &RelativePath) -> Self { Self::try_from( rhs.0 @@ -227,6 +228,7 @@ impl SystemPath { /// use it as the prefix directory for a [`RelativePath`]. It is up to the caller to make /// sure the resulting path is valid for use. #[must_use] + #[allow(clippy::missing_panics_doc)] pub fn join(&self, rhs: &RelativePath) -> Self { Self::try_from( rhs.0