Skip to content

Commit e7ca075

Browse files
author
Jon Gjengset
committed
Handle allow-features in add()
1 parent dc35abf commit e7ca075

File tree

1 file changed

+14
-22
lines changed

1 file changed

+14
-22
lines changed

src/cargo/core/features.rs

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -647,33 +647,15 @@ impl CliUnstable {
647647
);
648648
}
649649
let mut warnings = Vec::new();
650+
// We read flags twice, first to get allowed-features (if specified),
651+
// and then to read the remaining unstable flags.
650652
for flag in flags {
651653
if flag.starts_with("allow-features=") {
652654
self.add(flag, &mut warnings)?;
653655
}
654656
}
655-
if let Some(allowed) = self.allow_features.take() {
656-
for flag in flags {
657-
let k = flag
658-
.splitn(2, '=')
659-
.next()
660-
.expect("split always yields >=1 item");
661-
if k == "allow-features" {
662-
} else if allowed.contains(k) {
663-
self.add(flag, &mut warnings)?;
664-
} else {
665-
bail!(
666-
"the feature `{}` is not in the list of allowed features: {:?}",
667-
k,
668-
allowed
669-
);
670-
}
671-
}
672-
self.allow_features = Some(allowed);
673-
} else {
674-
for flag in flags {
675-
self.add(flag, &mut warnings)?;
676-
}
657+
for flag in flags {
658+
self.add(flag, &mut warnings)?;
677659
}
678660
Ok(warnings)
679661
}
@@ -744,6 +726,16 @@ impl CliUnstable {
744726
))
745727
};
746728

729+
if let Some(allowed) = &self.allow_features {
730+
if k != "allow-features" && !allowed.contains(k) {
731+
bail!(
732+
"the feature `{}` is not in the list of allowed features: {:?}",
733+
k,
734+
allowed
735+
);
736+
}
737+
}
738+
747739
match k {
748740
"print-im-a-teapot" => self.print_im_a_teapot = parse_bool(k, v)?,
749741
"allow-features" => self.allow_features = Some(parse_features(v).into_iter().collect()),

0 commit comments

Comments
 (0)