Skip to content

Commit b5453f3

Browse files
committed
inline the filter
1 parent 3bd1005 commit b5453f3

File tree

2 files changed

+13
-19
lines changed

2 files changed

+13
-19
lines changed

src/cargo/core/resolver/conflict_cache.rs

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,14 @@ enum ConflictStoreTrie {
1717
impl ConflictStoreTrie {
1818
/// Finds any known set of conflicts, if any,
1919
/// which are activated in `cx` and pass the `filter` specified?
20-
fn find_conflicting<F>(
20+
fn find_conflicting(
2121
&self,
2222
cx: &Context,
23-
filter: &F,
24-
) -> Option<&BTreeMap<PackageId, ConflictReason>>
25-
where
26-
for<'r> F: Fn(&'r &BTreeMap<PackageId, ConflictReason>) -> bool,
27-
{
23+
must_contain: Option<PackageId>,
24+
) -> Option<&BTreeMap<PackageId, ConflictReason>> {
2825
match self {
2926
ConflictStoreTrie::Leaf(c) => {
30-
if filter(&c) {
27+
if must_contain.map(|f| c.contains_key(&f)).unwrap_or(true) {
3128
// is_conflicting checks that all the elements are active,
3229
// but we have checked each one by the recursion of this function.
3330
debug_assert!(cx.is_conflicting(None, c));
@@ -40,7 +37,7 @@ impl ConflictStoreTrie {
4037
for (&pid, store) in m {
4138
// if the key is active then we need to check all of the corresponding subTrie.
4239
if cx.is_active(pid) {
43-
if let Some(o) = store.find_conflicting(cx, filter) {
40+
if let Some(o) = store.find_conflicting(cx, must_contain) {
4441
return Some(o);
4542
}
4643
} // else, if it is not active then there is no way any of the corresponding
@@ -134,23 +131,22 @@ impl ConflictCache {
134131
}
135132
/// Finds any known set of conflicts, if any,
136133
/// which are activated in `cx` and pass the `filter` specified?
137-
pub fn find_conflicting<F>(
134+
pub fn find_conflicting(
138135
&self,
139136
cx: &Context,
140137
dep: &Dependency,
141-
filter: F,
142-
) -> Option<&BTreeMap<PackageId, ConflictReason>>
143-
where
144-
for<'r> F: Fn(&'r &BTreeMap<PackageId, ConflictReason>) -> bool,
145-
{
146-
self.con_from_dep.get(dep)?.find_conflicting(cx, &filter)
138+
must_contain: Option<PackageId>,
139+
) -> Option<&BTreeMap<PackageId, ConflictReason>> {
140+
self.con_from_dep
141+
.get(dep)?
142+
.find_conflicting(cx, must_contain)
147143
}
148144
pub fn conflicting(
149145
&self,
150146
cx: &Context,
151147
dep: &Dependency,
152148
) -> Option<&BTreeMap<PackageId, ConflictReason>> {
153-
self.find_conflicting(cx, dep, |_| true)
149+
self.find_conflicting(cx, dep, None)
154150
}
155151

156152
/// Add to the cache a conflict of the form:

src/cargo/core/resolver/mod.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -442,9 +442,7 @@ fn activate_deps_loop(
442442
})
443443
.filter_map(|(other_parent, other_dep)| {
444444
past_conflicting_activations
445-
.find_conflicting(&cx, &other_dep, |con| {
446-
con.contains_key(&pid)
447-
})
445+
.find_conflicting(&cx, &other_dep, Some(pid))
448446
.map(|con| (other_parent, con))
449447
})
450448
.next()

0 commit comments

Comments
 (0)