Skip to content

Commit 756f54c

Browse files
committed
map_source for ReplacedSource
1 parent 6953ef8 commit 756f54c

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/cargo/core/package_id.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,14 @@ impl PackageId {
155155
PackageId::pure(self.inner.name, self.inner.version.clone(), source)
156156
}
157157

158+
pub fn map_source(self, to_replace: SourceId, replace_with: SourceId) -> Self {
159+
if self.source_id() == to_replace {
160+
self.with_source_id(replace_with)
161+
} else {
162+
self
163+
}
164+
}
165+
158166
pub fn stable_hash(self, workspace: &Path) -> PackageIdStableHash<'_> {
159167
PackageIdStableHash(self, workspace)
160168
}

src/cargo/sources/config.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,14 @@ impl<'cfg> SourceConfigMap<'cfg> {
120120
)
121121
}
122122
}
123-
let new_src = new_id.load(self.config, yanked_whitelist)?;
123+
124+
let new_src = new_id.load(
125+
self.config,
126+
&yanked_whitelist
127+
.iter()
128+
.map(|p| p.map_source(id, new_id))
129+
.collect(),
130+
)?;
124131
let old_src = id.load(self.config, yanked_whitelist)?;
125132
if !new_src.supports_checksums() && old_src.supports_checksums() {
126133
failure::bail!(

0 commit comments

Comments
 (0)