From 0075be7f88974569fe7ae8a74fc966eef7321771 Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Tue, 10 Oct 2023 06:58:40 +0900 Subject: [PATCH] Fix clippy warnings from rustc 1.73 --- src/hg_bundle.rs | 3 ++- src/hg_connect.rs | 27 +++++++++++++-------------- src/main.rs | 11 ++++------- 3 files changed, 19 insertions(+), 22 deletions(-) diff --git a/src/hg_bundle.rs b/src/hg_bundle.rs index 4b8cfe678..fcb9db833 100644 --- a/src/hg_bundle.rs +++ b/src/hg_bundle.rs @@ -1105,7 +1105,8 @@ fn bundle_manifest( let git_node = node.to_git().unwrap(); let git_parents = [parent1, parent2] .into_iter() - .filter_map(|p| (!p.is_null()).then(|| (p.to_git().unwrap().into()))) + .filter(|p| !p.is_null()) + .map(|p| (p.to_git().unwrap().into())) .collect_vec(); for (path, (hg_file, hg_fileparents)) in get_changes(git_node.into(), &git_parents, false).map(WithPath::unzip) diff --git a/src/hg_connect.rs b/src/hg_connect.rs index 532bcfab7..5332163e8 100644 --- a/src/hg_connect.rs +++ b/src/hg_connect.rs @@ -655,17 +655,17 @@ pub fn find_common( } let sample = take_sample::<_, _, SAMPLE_SIZE>(&mut rng, &mut undetermined); - let (known, unknown): (Vec<_>, Vec<_>) = conn - .known(&sample) - .iter() - .zip(sample.into_iter()) - .partition_map(|(&known, head)| { - if known { - Either::Left(head) - } else { - Either::Right(head) - } - }); + let (known, unknown): (Vec<_>, Vec<_>) = + conn.known(&sample) + .iter() + .zip(sample) + .partition_map(|(&known, head)| { + if known { + Either::Left(head) + } else { + Either::Right(head) + } + }); if undetermined.is_empty() && unknown.is_empty() { return known; @@ -775,9 +775,8 @@ pub fn find_common( } } dag.iter() - .filter_map(|(_, data)| { - (data.known == Some(true) && !data.has_known_children).then(|| data.hg_node.unwrap()) - }) + .filter(|(_, data)| data.known == Some(true) && !data.has_known_children) + .map(|(_, data)| data.hg_node.unwrap()) .collect_vec() } diff --git a/src/main.rs b/src/main.rs index 5891e2c02..8033abf66 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1141,7 +1141,7 @@ fn do_unbundle(clonebundle: bool, mut url: OsString) -> Result<(), String> { } let mut url = hg_url(&url).unwrap(); if !["http", "https", "file"].contains(&url.scheme()) { - return Err(format!("{} urls are not supported.", url.scheme())); + Err(format!("{} urls are not supported.", url.scheme()))?; } if graft_config_enabled(None)?.unwrap_or(false) { init_graft(); @@ -1149,7 +1149,7 @@ fn do_unbundle(clonebundle: bool, mut url: OsString) -> Result<(), String> { if clonebundle { let mut conn = get_connection(&url).unwrap(); if conn.get_capability(b"clonebundles").is_none() { - return Err("Repository does not support clonebundles")?; + Err("Repository does not support clonebundles")?; } url = get_clonebundle_url(&mut *conn).ok_or("Repository didn't provide a clonebundle")?; eprintln!("Getting clone bundle from {}", url); @@ -3497,11 +3497,8 @@ fn remote_helper_push( .lock() .unwrap() .branch_heads() - .filter_map(|(h, b)| { - branch_names - .contains(b) - .then(|| format!("^{}", h.to_git().unwrap())) - }) + .filter(|(h, b)| branch_names.contains(b)) + .map(|(h, b)| format!("^{}", h.to_git().unwrap())) .chain(push_commits.iter().map(ToString::to_string)) .chain(["--topo-order".to_string(), "--full-history".to_string()]), )