Skip to content

Commit a7168a8

Browse files
committed
Auto merge of rust-lang#14712 - Veykril:metadata-extra-args, r=Veykril
fix: Only pass unstable flags to cargo metadata from extra args config
2 parents c9b4116 + 16b3feb commit a7168a8

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

crates/project-model/src/cargo_workspace.rs

+15-2
Original file line numberDiff line numberDiff line change
@@ -294,12 +294,25 @@ impl CargoWorkspace {
294294
}
295295
meta.current_dir(current_dir.as_os_str());
296296

297-
let mut other_options = config.extra_args.clone();
297+
let mut other_options = vec![];
298+
// cargo metadata only supports a subset of flags of what cargo usually accepts, and usually
299+
// the only relevant flags for metadata here are unstable ones, so we pass those along
300+
// but nothing else
301+
let mut extra_args = config.extra_args.iter();
302+
while let Some(arg) = extra_args.next() {
303+
if arg == "-Z" {
304+
if let Some(arg) = extra_args.next() {
305+
other_options.push("-Z".to_owned());
306+
other_options.push(arg.to_owned());
307+
}
308+
}
309+
}
310+
298311
if !targets.is_empty() {
299312
other_options.append(
300313
&mut targets
301314
.into_iter()
302-
.flat_map(|target| ["--filter-platform".to_string(), target])
315+
.flat_map(|target| ["--filter-platform".to_owned().to_string(), target])
303316
.collect(),
304317
);
305318
}

0 commit comments

Comments
 (0)