Skip to content

Commit 5dec1b4

Browse files
committed
do not query feature related args when they don't exist
1 parent 966d644 commit 5dec1b4

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

src/lib.rs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -280,16 +280,18 @@ To see all the flags the proxied tool accepts run `cargo-{} -- --help`.{}",
280280

281281
pub fn run(tool: Tool, matches: ArgMatches) -> Result<i32> {
282282
let mut metadata_command = MetadataCommand::new();
283-
if let Some(features) = matches.get_many::<String>("features") {
284-
metadata_command.features(CargoOpt::SomeFeatures(
285-
features.map(|s| s.to_owned()).collect(),
286-
));
287-
}
288-
if matches.get_flag("no-default-features") {
289-
metadata_command.features(CargoOpt::NoDefaultFeatures);
290-
}
291-
if matches.get_flag("all-features") {
292-
metadata_command.features(CargoOpt::AllFeatures);
283+
if tool.needs_build() {
284+
if let Some(features) = matches.get_many::<String>("features") {
285+
metadata_command.features(CargoOpt::SomeFeatures(
286+
features.map(|s| s.to_owned()).collect(),
287+
));
288+
}
289+
if matches.get_flag("no-default-features") {
290+
metadata_command.features(CargoOpt::NoDefaultFeatures);
291+
}
292+
if matches.get_flag("all-features") {
293+
metadata_command.features(CargoOpt::AllFeatures);
294+
}
293295
}
294296
if let Some(path) = matches.get_one::<String>("manifest-path") {
295297
metadata_command.manifest_path(path);

0 commit comments

Comments
 (0)