Skip to content

Commit 16b3feb

Browse files
committed
Only pass unstable flags to cargo metadata from extra args config
1 parent 9c0c13e commit 16b3feb

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
@@ -293,12 +293,25 @@ impl CargoWorkspace {
293293
}
294294
meta.current_dir(current_dir.as_os_str());
295295

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

0 commit comments

Comments
 (0)