diff --git a/src/bin/cargo/commands/rustc.rs b/src/bin/cargo/commands/rustc.rs index 999f8d64c39..454282f0e6e 100644 --- a/src/bin/cargo/commands/rustc.rs +++ b/src/bin/cargo/commands/rustc.rs @@ -91,7 +91,16 @@ pub fn exec(gctx: &mut GlobalContext, args: &ArgMatches) -> CliResult { ops::print(&ws, &compile_opts, opt_value)?; return Ok(()); } - let crate_types = values(args, CRATE_TYPE_ARG_NAME); + + let crate_types = args + .get_many::(CRATE_TYPE_ARG_NAME) + .into_iter() + .flatten() + .flat_map(|s| s.split(',')) + .filter(|s| !s.is_empty()) + .map(String::from) + .collect::>(); + compile_opts.target_rustc_crate_types = if crate_types.is_empty() { None } else { diff --git a/tests/testsuite/rustc.rs b/tests/testsuite/rustc.rs index c3afb6a01b0..9222255aa58 100644 --- a/tests/testsuite/rustc.rs +++ b/tests/testsuite/rustc.rs @@ -238,7 +238,7 @@ fn build_with_crate_types_for_foo() { p.cargo("rustc -v --crate-type lib,cdylib") .with_stderr_data(str![[r#" [COMPILING] foo v0.0.1 ([ROOT]/foo) -[RUNNING] `rustc --crate-name foo --edition=2015 src/lib.rs [..]--crate-type lib,cdylib [..]` +[RUNNING] `rustc --crate-name foo --edition=2015 src/lib.rs [..]--crate-type lib --crate-type cdylib [..]` [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s "#]]) @@ -302,7 +302,7 @@ fn build_with_crate_types_to_example() { .with_stderr_data(str![[r#" [COMPILING] foo v0.0.1 ([ROOT]/foo) [RUNNING] `rustc --crate-name foo --edition=2015 src/lib.rs [..]--crate-type lib [..]` -[RUNNING] `rustc --crate-name ex --edition=2015 examples/ex.rs [..]--crate-type lib,cdylib [..]` +[RUNNING] `rustc --crate-name ex --edition=2015 examples/ex.rs [..]--crate-type lib --crate-type cdylib [..]` [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s "#]]) @@ -338,7 +338,7 @@ fn build_with_crate_types_to_one_of_multi_examples() { .with_stderr_data(str![[r#" [COMPILING] foo v0.0.1 ([ROOT]/foo) [RUNNING] `rustc --crate-name foo --edition=2015 src/lib.rs [..]--crate-type lib [..]` -[RUNNING] `rustc --crate-name ex1 --edition=2015 examples/ex1.rs [..]--crate-type lib,cdylib [..]` +[RUNNING] `rustc --crate-name ex1 --edition=2015 examples/ex1.rs [..]--crate-type lib --crate-type cdylib [..]` [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s "#]])