Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Forward unstable feature flags (-Z) to cargo metadata invocations #1517

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/bin/commands/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ impl Run {
let args = Args {
cargo_args: vec![],
rest_args: vec![],
unstable_features: vec![],
subcommand: None,
channel: None,
target: Some(target.clone()),
Expand Down
7 changes: 7 additions & 0 deletions src/cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,13 @@ pub fn cargo_metadata_with_args(
if let Some(features) = args.map(|a| &a.features).filter(|v| !v.is_empty()) {
command.args([String::from("--features"), features.join(",")]);
}
if let Some(unstable_features) = args.map(|a| &a.unstable_features).filter(|v| !v.is_empty()) {
command.args(
unstable_features
.iter()
.flat_map(|f| [String::from("-Z"), f.to_owned()]),
);
}
let output = command.run_and_get_output(msg_info)?;
if !output.status.success() {
msg_info.warn("unable to get metadata for package")?;
Expand Down
26 changes: 26 additions & 0 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pub struct Args {
pub channel: Option<String>,
pub target: Option<Target>,
pub features: Vec<String>,
pub unstable_features: Vec<String>,
pub target_dir: Option<PathBuf>,
pub manifest_path: Option<PathBuf>,
pub version: bool,
Expand Down Expand Up @@ -170,6 +171,7 @@ pub fn parse(target_list: &TargetList) -> Result<Args> {
let mut quiet = false;
let mut verbose = 0;
let mut color = None;
let mut unstable_features = Vec::new();

{
let mut args = env::args().skip(1);
Expand Down Expand Up @@ -264,6 +266,29 @@ pub fn parse(target_list: &TargetList) -> Result<Args> {
)?);
}
}
} else if let Some(kind) = is_value_arg(&arg, "-Z") {
match kind {
ArgKind::Next => {
let next = parse_next_arg(
arg,
&mut cargo_args,
str_to_owned,
identity,
&mut args,
)?;
if let Some(feature) = next {
unstable_features.push(feature);
}
}
ArgKind::Equal => {
unstable_features.push(parse_equal_arg(
arg,
&mut cargo_args,
str_to_owned,
identity,
)?);
}
}
} else if let Some(kind) = is_value_arg(&arg, "--target-dir") {
match kind {
ArgKind::Next => {
Expand Down Expand Up @@ -299,6 +324,7 @@ pub fn parse(target_list: &TargetList) -> Result<Args> {
rest_args,
subcommand: sc,
channel,
unstable_features,
target,
features,
target_dir,
Expand Down
Loading