Only pass unstable flags to cargo metadata from extra args config

This commit is contained in:
Lukas Wirth 2023-05-02 09:16:26 +02:00
parent 9c0c13ec8e
commit 16b3febcf5

View File

@ -293,12 +293,25 @@ pub fn fetch_metadata(
}
meta.current_dir(current_dir.as_os_str());
let mut other_options = config.extra_args.clone();
let mut other_options = vec![];
// cargo metadata only supports a subset of flags of what cargo usually accepts, and usually
// the only relevant flags for metadata here are unstable ones, so we pass those along
// but nothing else
let mut extra_args = config.extra_args.iter();
while let Some(arg) = extra_args.next() {
if arg == "-Z" {
if let Some(arg) = extra_args.next() {
other_options.push("-Z".to_owned());
other_options.push(arg.to_owned());
}
}
}
if !targets.is_empty() {
other_options.append(
&mut targets
.into_iter()
.flat_map(|target| ["--filter-platform".to_string(), target])
.flat_map(|target| ["--filter-platform".to_owned().to_string(), target])
.collect(),
);
}