mirror of
https://github.com/rust-lang/cargo
synced 2024-08-25 02:25:46 +00:00
Add future compatibility warning on mixture of --release with --profile.
This was historically allowed, but it silently ignores the --release flag.
This commit is contained in:
parent
56b9ce30ac
commit
595384ffda
|
@ -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));
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
|
|
|
@ -360,7 +360,7 @@ fn conflicting_usage() {
|
|||
authors = []
|
||||
"#,
|
||||
)
|
||||
.file("src/lib.rs", "")
|
||||
.file("src/main.rs", "fn main() {}")
|
||||
.build();
|
||||
|
||||
p.cargo("build --profile=dev --release")
|
||||
|
@ -381,6 +381,82 @@ Remove one flag or the other to continue.
|
|||
error: conflicting usage of --profile=release and --debug
|
||||
The `--debug` flag is the same as `--profile=dev`.
|
||||
Remove one flag or the other to continue.
|
||||
",
|
||||
)
|
||||
.run();
|
||||
|
||||
p.cargo("rustc --profile=dev --release")
|
||||
.with_stderr(
|
||||
"\
|
||||
warning: the `--release` flag should not be specified with the `--profile` flag
|
||||
The `--release` flag will be ignored.
|
||||
This was historically accepted, but will become an error in a future release.
|
||||
[COMPILING] foo [..]
|
||||
[FINISHED] dev [..]
|
||||
",
|
||||
)
|
||||
.run();
|
||||
|
||||
p.cargo("check --profile=dev --release")
|
||||
.with_status(101)
|
||||
.with_stderr(
|
||||
"\
|
||||
error: conflicting usage of --profile=dev and --release
|
||||
The `--release` flag is the same as `--profile=release`.
|
||||
Remove one flag or the other to continue.
|
||||
",
|
||||
)
|
||||
.run();
|
||||
|
||||
p.cargo("check --profile=test --release")
|
||||
.with_stderr(
|
||||
"\
|
||||
warning: the `--release` flag should not be specified with the `--profile` flag
|
||||
The `--release` flag will be ignored.
|
||||
This was historically accepted, but will become an error in a future release.
|
||||
[CHECKING] foo [..]
|
||||
[FINISHED] test [..]
|
||||
",
|
||||
)
|
||||
.run();
|
||||
|
||||
// This is OK since the two are the same.
|
||||
p.cargo("rustc --profile=release --release")
|
||||
.with_stderr(
|
||||
"\
|
||||
[COMPILING] foo [..]
|
||||
[FINISHED] release [..]
|
||||
",
|
||||
)
|
||||
.run();
|
||||
|
||||
p.cargo("build --profile=release --release")
|
||||
.with_stderr(
|
||||
"\
|
||||
[FINISHED] release [..]
|
||||
",
|
||||
)
|
||||
.run();
|
||||
|
||||
p.cargo("install --path . --profile=dev --debug")
|
||||
.with_stderr(
|
||||
"\
|
||||
[INSTALLING] foo [..]
|
||||
[FINISHED] dev [..]
|
||||
[INSTALLING] [..]
|
||||
[INSTALLED] [..]
|
||||
[WARNING] be sure to add [..]
|
||||
",
|
||||
)
|
||||
.run();
|
||||
|
||||
p.cargo("install --path . --profile=release --debug")
|
||||
.with_status(101)
|
||||
.with_stderr(
|
||||
"\
|
||||
error: conflicting usage of --profile=release and --debug
|
||||
The `--debug` flag is the same as `--profile=dev`.
|
||||
Remove one flag or the other to continue.
|
||||
",
|
||||
)
|
||||
.run();
|
||||
|
|
Loading…
Reference in a new issue