]> git.proxmox.com Git - cargo.git/blobdiff - src/cargo/util/command_prelude.rs
Add future compatibility warning on mixture of --release with --profile.
[cargo.git] / src / cargo / util / command_prelude.rs
index afe3d68abff7b5c387bcb3e2405556502d2cd7ac..d0cf17824b1e3cdc09fb3ba4f23d2186b521a712 100644 (file)
@@ -353,7 +353,7 @@ pub trait ArgMatchesExt {
 
     fn get_profile_name(
         &self,
-        _config: &Config,
+        config: &Config,
         default: &str,
         profile_checking: ProfileChecking,
     ) -> CargoResult<InternedString> {
@@ -363,9 +363,19 @@ pub trait ArgMatchesExt {
         // This is an early exit, since it allows combination with `--release`.
         match (specified_profile, profile_checking) {
             // `cargo rustc` has legacy handling of these names
-            (Some(name @ ("dev" | "test" | "bench" | "check")), ProfileChecking::LegacyRustc) |
+            (Some(name @ ("dev" | "test" | "bench" | "check")), ProfileChecking::LegacyRustc)
             // `cargo fix` and `cargo check` has legacy handling of this profile name
-            (Some(name @ "test"), ProfileChecking::LegacyTestOnly) => return Ok(InternedString::new(name)),
+            | (Some(name @ "test"), ProfileChecking::LegacyTestOnly) => {
+                if self._is_present("release") {
+                    config.shell().warn(
+                        "the `--release` flag should not be specified with the `--profile` flag\n\
+                         The `--release` flag will be ignored.\n\
+                         This was historically accepted, but will become an error \
+                         in a future release."
+                    )?;
+                }
+                return Ok(InternedString::new(name));
+            }
             _ => {}
         }