Skip to content

Commit 53b535f

Browse files
committed
remove the use of NLL
1 parent 4c8ab5e commit 53b535f

File tree

2 files changed

+21
-23
lines changed

2 files changed

+21
-23
lines changed

src/cargo/core/resolver/conflict_cache.rs

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,23 @@ impl ConflictStore {
4040
}
4141
}
4242
}
43+
44+
pub fn insert<'a>(
45+
&mut self,
46+
mut iter: impl Iterator<Item = &'a PackageId>,
47+
con: BTreeMap<PackageId, ConflictReason>,
48+
) {
49+
if let Some(pid) = iter.next() {
50+
if let ConflictStore::Map(p) = self {
51+
p.entry(pid.clone())
52+
.or_insert_with(|| ConflictStore::Map(HashMap::new()))
53+
.insert(iter, con);
54+
}
55+
// else, We already have a subset of this in the ConflictStore
56+
} else {
57+
*self = ConflictStore::Con(con)
58+
}
59+
}
4360
}
4461

4562
pub(super) struct ConflictCache {
@@ -113,30 +130,11 @@ impl ConflictCache {
113130
/// `dep` is known to be unresolvable if
114131
/// all the `PackageId` entries are activated
115132
pub fn insert(&mut self, dep: &Dependency, con: &BTreeMap<PackageId, ConflictReason>) {
116-
let mut past = self
117-
.con_from_dep
133+
self.con_from_dep
118134
.entry(dep.clone())
119-
.or_insert_with(|| ConflictStore::Map(HashMap::new()));
120-
121-
for pid in con.keys() {
122-
match past {
123-
ConflictStore::Con(_) => {
124-
// We already have a subset of this in the ConflictStore
125-
return;
126-
}
127-
ConflictStore::Map(p) => {
128-
past = p
129-
.entry(pid.clone())
130-
.or_insert_with(|| ConflictStore::Map(HashMap::new()));
131-
}
132-
}
133-
}
135+
.or_insert_with(|| ConflictStore::Map(HashMap::new()))
136+
.insert(con.keys(), con.clone());
134137

135-
if let ConflictStore::Con(_) = past {
136-
// We already have this in the ConflictStore
137-
return;
138-
}
139-
*past = ConflictStore::Con(con.clone());
140138
trace!(
141139
"{} = \"{}\" adding a skip {:?}",
142140
dep.package_name(),

src/cargo/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![cfg_attr(test, deny(warnings))]
2-
#![feature(nll)]
2+
33
// Clippy isn't enforced by CI, and know that @alexcrichton isn't a fan :)
44
#![cfg_attr(feature = "cargo-clippy", allow(boxed_local))] // bug rust-lang-nursery/rust-clippy#1123
55
#![cfg_attr(feature = "cargo-clippy", allow(cyclomatic_complexity))] // large project

0 commit comments

Comments
 (0)