From 07b17b9dab56fb3030f6d726f000c398713deae6 Mon Sep 17 00:00:00 2001 From: Joe Neeman Date: Tue, 4 Jun 2024 16:25:37 -0500 Subject: [PATCH] load_and_overlay -> load_unreplaced --- src/cargo/sources/config.rs | 39 +++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/src/cargo/sources/config.rs b/src/cargo/sources/config.rs index 160fa4c60e56..112474082684 100644 --- a/src/cargo/sources/config.rs +++ b/src/cargo/sources/config.rs @@ -145,22 +145,6 @@ impl<'gctx> SourceConfigMap<'gctx> { self.gctx } - fn load_and_overlay( - &self, - id: SourceId, - yanked_whitelist: &HashSet, - ) -> CargoResult> { - let src = id.load(self.gctx, yanked_whitelist)?; - if let Some(overlay_id) = self.overlays.get(&id) { - let overlay = overlay_id.load(self.gctx(), yanked_whitelist)?; - Ok(Box::new(DependencyConfusionThreatOverlaySource::new( - overlay, src, - ))) - } else { - Ok(src) - } - } - /// Gets the [`Source`] for a given [`SourceId`]. /// /// * `yanked_whitelist` --- Packages allowed to be used, even if they are yanked. @@ -172,7 +156,7 @@ impl<'gctx> SourceConfigMap<'gctx> { debug!("loading: {}", id); let Some(mut name) = self.id2name.get(&id) else { - return self.load_and_overlay(id, yanked_whitelist); + return self.load_unreplaced(id, yanked_whitelist); }; let mut cfg_loc = ""; let orig_name = name; @@ -197,7 +181,7 @@ impl<'gctx> SourceConfigMap<'gctx> { name = s; cfg_loc = c; } - None if id == cfg.id => return self.load_and_overlay(id, yanked_whitelist), + None if id == cfg.id => return self.load_unreplaced(id, yanked_whitelist), None => { break cfg.id.with_precise_from(id); } @@ -214,7 +198,7 @@ impl<'gctx> SourceConfigMap<'gctx> { } }; - let new_src = self.load_and_overlay( + let new_src = self.load_unreplaced( new_id, &yanked_whitelist .iter() @@ -251,6 +235,23 @@ restore the source replacement configuration to continue the build Ok(Box::new(ReplacedSource::new(id, new_id, new_src))) } + /// Gets the [`Source`] for a given [`SourceId`] without performing any source replacement. + fn load_unreplaced( + &self, + id: SourceId, + yanked_whitelist: &HashSet, + ) -> CargoResult> { + let src = id.load(self.gctx, yanked_whitelist)?; + if let Some(overlay_id) = self.overlays.get(&id) { + let overlay = overlay_id.load(self.gctx(), yanked_whitelist)?; + Ok(Box::new(DependencyConfusionThreatOverlaySource::new( + overlay, src, + ))) + } else { + Ok(src) + } + } + /// Adds a source config with an associated name. fn add(&mut self, name: &str, cfg: SourceConfig) -> CargoResult<()> { if let Some(old_name) = self.id2name.insert(cfg.id, name.to_string()) {