Skip to content

Commit aa6b7e0

Browse files
committed
Auto merge of #7419 - alexcrichton:fix-features-regression, r=ehuss
Fix interpretation of `--features a b` on the CLI Fixes an accidental regression from #7084 where `--features a b` was erroneously mistinterpreted as `--features "a b"`. Closes #7418
2 parents 068a9b6 + 1fa02e7 commit aa6b7e0

File tree

2 files changed

+34
-5
lines changed

2 files changed

+34
-5
lines changed

src/cargo/util/command_prelude.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,11 @@ pub trait AppExt: Sized {
100100
}
101101

102102
fn arg_features(self) -> Self {
103-
self._arg(
104-
opt("features", "Space-separated list of features to activate")
105-
.multiple(true)
106-
.value_name("FEATURES"),
107-
)
103+
self._arg(multi_opt(
104+
"features",
105+
"FEATURES",
106+
"Space-separated list of features to activate",
107+
))
108108
._arg(opt("all-features", "Activate all available features"))
109109
._arg(opt(
110110
"no-default-features",

tests/testsuite/features.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1959,3 +1959,32 @@ fn multi_multi_features() {
19591959

19601960
p.cargo("build --features a --features").arg("b c").run();
19611961
}
1962+
1963+
#[cargo_test]
1964+
fn cli_parse_ok() {
1965+
let p = project()
1966+
.file(
1967+
"Cargo.toml",
1968+
r#"
1969+
[project]
1970+
name = "foo"
1971+
version = "0.0.1"
1972+
authors = []
1973+
1974+
[features]
1975+
a = []
1976+
"#,
1977+
)
1978+
.file(
1979+
"src/main.rs",
1980+
r#"
1981+
#[cfg(feature = "a")]
1982+
fn main() {
1983+
assert_eq!(std::env::args().nth(1).unwrap(), "b");
1984+
}
1985+
"#,
1986+
)
1987+
.build();
1988+
1989+
p.cargo("run --features a b").run();
1990+
}

0 commit comments

Comments
 (0)