From a3a70218f3cc438b4875a046a182ca44dab357ae Mon Sep 17 00:00:00 2001 From: Amr Bashir Date: Tue, 25 Oct 2022 15:26:30 +0200 Subject: [PATCH] fix(cli): pass `--no-default-features` to runner instead of app, closes #5415 (#5474) --- .changes/cli-no-default-featurs-arg.md | 5 +++++ tooling/cli/src/interface/rust.rs | 29 +++++++++++++------------- 2 files changed, 20 insertions(+), 14 deletions(-) create mode 100644 .changes/cli-no-default-featurs-arg.md diff --git a/.changes/cli-no-default-featurs-arg.md b/.changes/cli-no-default-featurs-arg.md new file mode 100644 index 000000000..a8f845998 --- /dev/null +++ b/.changes/cli-no-default-featurs-arg.md @@ -0,0 +1,5 @@ +--- +"cli.rs": "patch" +--- + +Fix cli passing `--no-default-features` to the app instead of the runner (Cargo). diff --git a/tooling/cli/src/interface/rust.rs b/tooling/cli/src/interface/rust.rs index 2ed6402f5..a603bd218 100644 --- a/tooling/cli/src/interface/rust.rs +++ b/tooling/cli/src/interface/rust.rs @@ -285,7 +285,20 @@ impl Rust { mut options: Options, on_exit: F, ) -> crate::Result { - if !options.args.contains(&"--no-default-features".into()) { + let mut args = Vec::new(); + let mut run_args = Vec::new(); + let mut reached_run_args = false; + for arg in options.args.clone() { + if reached_run_args { + run_args.push(arg); + } else if arg == "--" { + reached_run_args = true; + } else { + args.push(arg); + } + } + + if !args.contains(&"--no-default-features".into()) { let manifest_features = self.app_settings.manifest.features(); let enable_features: Vec = manifest_features .get("default") @@ -300,7 +313,7 @@ impl Rust { } }) .collect(); - options.args.push("--no-default-features".into()); + args.push("--no-default-features".into()); if !enable_features.is_empty() { options .features @@ -309,18 +322,6 @@ impl Rust { } } - let mut args = Vec::new(); - let mut run_args = Vec::new(); - let mut reached_run_args = false; - for arg in options.args.clone() { - if reached_run_args { - run_args.push(arg); - } else if arg == "--" { - reached_run_args = true; - } else { - args.push(arg); - } - } options.args = args; desktop::run_dev(