@@ -131,7 +131,12 @@ pub trait CommandExt: Sized {
131
131
) -> Self {
132
132
let msg = format ! ( "`--{default_mode}` is the default for `cargo {command}`; instead `--{supported_mode}` is supported" ) ;
133
133
let value_parser = UnknownArgumentValueParser :: suggest ( msg) ;
134
- self . _arg ( flag ( default_mode, "" ) . value_parser ( value_parser) . hide ( true ) )
134
+ self . _arg (
135
+ flag ( default_mode, "" )
136
+ . conflicts_with ( "profile" )
137
+ . value_parser ( value_parser)
138
+ . hide ( true ) ,
139
+ )
135
140
}
136
141
137
142
fn arg_targets_all (
@@ -226,6 +231,7 @@ pub trait CommandExt: Sized {
226
231
self . _arg (
227
232
flag ( "release" , release)
228
233
. short ( 'r' )
234
+ . conflicts_with ( "profile" )
229
235
. help_heading ( heading:: COMPILATION_OPTIONS ) ,
230
236
)
231
237
}
@@ -568,7 +574,6 @@ Run `{cmd}` to see possible targets."
568
574
569
575
fn get_profile_name (
570
576
& self ,
571
- gctx : & GlobalContext ,
572
577
default : & str ,
573
578
profile_checking : ProfileChecking ,
574
579
) -> CargoResult < InternedString > {
@@ -581,40 +586,19 @@ Run `{cmd}` to see possible targets."
581
586
( Some ( name @ ( "dev" | "test" | "bench" | "check" ) ) , ProfileChecking :: LegacyRustc )
582
587
// `cargo fix` and `cargo check` has legacy handling of this profile name
583
588
| ( Some ( name @ "test" ) , ProfileChecking :: LegacyTestOnly ) => {
584
- if self . maybe_flag ( "release" ) {
585
- gctx. shell ( ) . warn (
586
- "the `--release` flag should not be specified with the `--profile` flag\n \
587
- The `--release` flag will be ignored.\n \
588
- This was historically accepted, but will become an error \
589
- in a future release."
590
- ) ?;
591
- }
592
589
return Ok ( InternedString :: new ( name) ) ;
593
590
}
594
591
_ => { }
595
592
}
596
593
597
- let conflict = |flag : & str , equiv : & str , specified : & str | -> anyhow:: Error {
598
- anyhow:: format_err!(
599
- "conflicting usage of --profile={} and --{flag}\n \
600
- The `--{flag}` flag is the same as `--profile={equiv}`.\n \
601
- Remove one flag or the other to continue.",
602
- specified,
603
- flag = flag,
604
- equiv = equiv
605
- )
606
- } ;
607
-
608
594
let name = match (
609
595
self . maybe_flag ( "release" ) ,
610
596
self . maybe_flag ( "debug" ) ,
611
597
specified_profile,
612
598
) {
613
599
( false , false , None ) => default,
614
- ( true , _, None | Some ( "release" ) ) => "release" ,
615
- ( true , _, Some ( name) ) => return Err ( conflict ( "release" , "release" , name) ) ,
616
- ( _, true , None | Some ( "dev" ) ) => "dev" ,
617
- ( _, true , Some ( name) ) => return Err ( conflict ( "debug" , "dev" , name) ) ,
600
+ ( true , _, None ) => "release" ,
601
+ ( _, true , None ) => "dev" ,
618
602
// `doc` is separate from all the other reservations because
619
603
// [profile.doc] was historically allowed, but is deprecated and
620
604
// has no effect. To avoid potentially breaking projects, it is a
@@ -720,7 +704,7 @@ Run `{cmd}` to see possible targets."
720
704
mode,
721
705
) ?;
722
706
build_config. message_format = message_format. unwrap_or ( MessageFormat :: Human ) ;
723
- build_config. requested_profile = self . get_profile_name ( gctx , "dev" , profile_checking) ?;
707
+ build_config. requested_profile = self . get_profile_name ( "dev" , profile_checking) ?;
724
708
build_config. build_plan = self . flag ( "build-plan" ) ;
725
709
build_config. unit_graph = self . flag ( "unit-graph" ) ;
726
710
build_config. future_incompat_report = self . flag ( "future-incompat-report" ) ;
0 commit comments