From 1e57d7a52363ec9578caae2c287d7ae3629e5231 Mon Sep 17 00:00:00 2001 From: Dan Aloni Date: Mon, 7 Oct 2019 23:09:17 +0300 Subject: [PATCH 1/3] named-profiles: when -Z unstable-options not specified, don't validate --profile Fixes #7488. --- src/cargo/util/command_prelude.rs | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/cargo/util/command_prelude.rs b/src/cargo/util/command_prelude.rs index 2d0a9b3fc5e..4a892cb6bb8 100644 --- a/src/cargo/util/command_prelude.rs +++ b/src/cargo/util/command_prelude.rs @@ -322,14 +322,22 @@ pub trait ArgMatchesExt { } if self._is_present("release") { - match specified_profile { - None | Some(ProfileKind::Release) => Ok(ProfileKind::Release), - _ => failure::bail!("Conflicting usage of --profile and --release"), + if !config.cli_unstable().unstable_options { + Ok(ProfileKind::Release) + } else { + match specified_profile { + None | Some(ProfileKind::Release) => Ok(ProfileKind::Release), + _ => failure::bail!("Conflicting usage of --profile and --release"), + } } } else if self._is_present("debug") { - match specified_profile { - None | Some(ProfileKind::Dev) => Ok(ProfileKind::Dev), - _ => failure::bail!("Conflicting usage of --profile and --debug"), + if !config.cli_unstable().unstable_options { + Ok(ProfileKind::Dev) + } else { + match specified_profile { + None | Some(ProfileKind::Dev) => Ok(ProfileKind::Dev), + _ => failure::bail!("Conflicting usage of --profile and --debug"), + } } } else { Ok(specified_profile.unwrap_or(default)) From e04099e6a3a1814254744661aad316946bff436f Mon Sep 17 00:00:00 2001 From: Dan Aloni Date: Tue, 8 Oct 2019 09:48:31 +0300 Subject: [PATCH 2/3] tests: cover issue #7488 --- tests/testsuite/check.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/testsuite/check.rs b/tests/testsuite/check.rs index e836cdb6b20..6bb21b8554c 100644 --- a/tests/testsuite/check.rs +++ b/tests/testsuite/check.rs @@ -335,6 +335,10 @@ fn rustc_check() { .build(); foo.cargo("rustc --profile check -- --emit=metadata").run(); + + // Verify compatible usage of --profile with --release, issue #7488 + foo.cargo("rustc --profile check --release -- --emit=metadata").run(); + foo.cargo("rustc --profile test --release -- --emit=metadata").run(); } #[cargo_test] From 9dc70a3dabb291052a4d117b8348c9b461d1b570 Mon Sep 17 00:00:00 2001 From: Dan Aloni Date: Tue, 8 Oct 2019 11:07:19 +0300 Subject: [PATCH 3/3] Rustfmt lint --- tests/testsuite/check.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/testsuite/check.rs b/tests/testsuite/check.rs index 6bb21b8554c..45b6a4bbe54 100644 --- a/tests/testsuite/check.rs +++ b/tests/testsuite/check.rs @@ -337,8 +337,10 @@ fn rustc_check() { foo.cargo("rustc --profile check -- --emit=metadata").run(); // Verify compatible usage of --profile with --release, issue #7488 - foo.cargo("rustc --profile check --release -- --emit=metadata").run(); - foo.cargo("rustc --profile test --release -- --emit=metadata").run(); + foo.cargo("rustc --profile check --release -- --emit=metadata") + .run(); + foo.cargo("rustc --profile test --release -- --emit=metadata") + .run(); } #[cargo_test]