From: Dirkjan Ochtman Date: Mon, 2 Oct 2017 16:04:28 +0000 (+0200) Subject: Extract method for handling feature requirements X-Git-Tag: archive/raspbian/0.35.0-2+rpi1~3^2^2^2^2^2^2^2~22^2~5^2~16^2~3 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=1b01e36f14a814bfbbe6ef0583811079f473432f;p=cargo.git Extract method for handling feature requirements --- diff --git a/src/cargo/core/resolver/mod.rs b/src/cargo/core/resolver/mod.rs index 4587fc08c..fd16ccf13 100644 --- a/src/cargo/core/resolver/mod.rs +++ b/src/cargo/core/resolver/mod.rs @@ -904,6 +904,16 @@ impl<'r> Requirements<'r> { self.deps.entry(pkg).or_insert((false, Vec::new())).0 = true; } + fn require_feature(&mut self, feat: &'r str, recursive: &'r Vec) -> CargoResult<()> { + for f in recursive { + if f == &feat { + bail!("Cyclic feature dependency: feature `{}` depends on itself", feat); + } + self.add_feature(f)?; + } + Ok(()) + } + fn add_feature(&mut self, feat: &'r str) -> CargoResult<()> { if feat.is_empty() { return Ok(()) } @@ -925,15 +935,7 @@ impl<'r> Requirements<'r> { } match self.summary.features().get(feat) { Some(recursive) => { - // This is a feature, add it recursively. - for f in recursive { - if f == feat { - bail!("Cyclic feature dependency: feature `{}` depends \ - on itself", feat); - } - - self.add_feature(f)?; - } + self.require_feature(feat, recursive)?; } None => { // This is a dependency, mark it as explicitly requested.