Skip to content

Commit

Permalink
Fix clippy 1.73 warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
glandium committed Oct 29, 2023
1 parent 230cce3 commit 68a48f8
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 31 deletions.
39 changes: 18 additions & 21 deletions src/hg_connect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -653,17 +653,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;
Expand Down Expand Up @@ -711,20 +711,20 @@ pub fn find_common(
undetermined_count += 1;
}
for (cs, c) in known {
if let Some((_, mut data)) = dag.get_mut(&*c) {
if let Some((_, data)) = dag.get_mut(&*c) {
data.hg_node = Some(cs.clone());
data.known = Some(true);
undetermined_count -= 1;
}
}
for (_, c) in unknown {
if let Some((_, mut data)) = dag.get_mut(&*c) {
if let Some((_, data)) = dag.get_mut(&*c) {
data.known = Some(false);
undetermined_count -= 1;
}
}
for (cs, c) in &undetermined {
if let Some((_, mut data)) = dag.get_mut(c) {
if let Some((_, data)) = dag.get_mut(c) {
data.hg_node = Some(cs.clone());
}
}
Expand Down Expand Up @@ -775,10 +775,8 @@ pub fn find_common(
}
}
dag.iter()
.filter_map(|(_, data)| {
(data.known == Some(true) && !data.has_known_children)
.then(|| data.hg_node.clone().unwrap())
})
.filter(|(_, data)| data.known == Some(true) && !data.has_known_children)
.map(|(_, data)| data.hg_node.clone().unwrap())
.collect_vec()
}

Expand All @@ -793,9 +791,8 @@ pub fn get_bundle(
.lock()
.unwrap()
.branch_heads()
.filter_map(|(h, b)| {
(branch_names.is_empty() || branch_names.contains(b)).then(|| h.clone())
})
.filter(|(_, b)| branch_names.is_empty() || branch_names.contains(b))
.map(|(h, _)| h.clone())
.collect_vec()
};

Expand Down
17 changes: 8 additions & 9 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,8 @@ fn do_rollback(
print!("{}", m);
let matched_labels = labels
.iter()
.filter_map(|(name, cid)| (*cid == m).then(|| *name))
.filter(|(_, cid)| *cid == m)
.map(|(name, _)| *name)
.collect_vec()
.join(", ");
if !matched_labels.is_empty() {
Expand Down Expand Up @@ -1135,15 +1136,15 @@ 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();
}
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);
Expand Down Expand Up @@ -3551,7 +3552,8 @@ fn remote_helper_import(
let mut tags = None;
let mut unknown_wanted_heads = wanted_refs
.iter()
.filter_map(|(_, csid, cid)| cid.is_none().then(|| (*csid).clone()))
.filter(|(_, _, cid)| cid.is_none())
.map(|(_, csid, _)| (*csid).clone())
.unique()
.collect_vec();
if !unknown_wanted_heads.is_empty() {
Expand Down Expand Up @@ -3719,11 +3721,8 @@ fn remote_helper_push(
.lock()
.unwrap()
.branch_heads()
.filter_map(|(h, b)| {
branch_names
.contains(b)
.then(|| format!("^{}", h.to_git().unwrap()))
})
.filter(|(_, b)| branch_names.contains(*b))
.map(|(h, _)| format!("^{}", h.to_git().unwrap()))
.chain(push_commits.iter().map(ToString::to_string))
.chain(["--topo-order".to_string(), "--full-history".to_string()]),
)
Expand Down
3 changes: 2 additions & 1 deletion src/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,8 @@ impl TagSet {
pub fn iter(&self) -> impl Iterator<Item = (&[u8], &HgChangesetId)> {
self.tags
.iter()
.filter_map(|(tag, (node, _))| (node != &HgChangesetId::null()).then(|| (&**tag, node)))
.filter(|(_, (node, _))| node != &HgChangesetId::null())
.map(|(tag, (node, _))| (&**tag, node))
}
}

Expand Down

0 comments on commit 68a48f8

Please sign in to comment.