@@ -131,7 +131,12 @@ pub trait CommandExt: Sized {
131131 ) -> Self {
132132 let msg = format ! ( "`--{default_mode}` is the default for `cargo {command}`; instead `--{supported_mode}` is supported" ) ;
133133 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+ )
135140 }
136141
137142 fn arg_targets_all (
@@ -226,6 +231,7 @@ pub trait CommandExt: Sized {
226231 self . _arg (
227232 flag ( "release" , release)
228233 . short ( 'r' )
234+ . conflicts_with ( "profile" )
229235 . help_heading ( heading:: COMPILATION_OPTIONS ) ,
230236 )
231237 }
@@ -568,7 +574,6 @@ Run `{cmd}` to see possible targets."
568574
569575 fn get_profile_name (
570576 & self ,
571- gctx : & GlobalContext ,
572577 default : & str ,
573578 profile_checking : ProfileChecking ,
574579 ) -> CargoResult < InternedString > {
@@ -581,40 +586,19 @@ Run `{cmd}` to see possible targets."
581586 ( Some ( name @ ( "dev" | "test" | "bench" | "check" ) ) , ProfileChecking :: LegacyRustc )
582587 // `cargo fix` and `cargo check` has legacy handling of this profile name
583588 | ( 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- }
592589 return Ok ( InternedString :: new ( name) ) ;
593590 }
594591 _ => { }
595592 }
596593
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-
608594 let name = match (
609595 self . maybe_flag ( "release" ) ,
610596 self . maybe_flag ( "debug" ) ,
611597 specified_profile,
612598 ) {
613599 ( 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" ,
618602 // `doc` is separate from all the other reservations because
619603 // [profile.doc] was historically allowed, but is deprecated and
620604 // has no effect. To avoid potentially breaking projects, it is a
@@ -720,7 +704,7 @@ Run `{cmd}` to see possible targets."
720704 mode,
721705 ) ?;
722706 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) ?;
724708 build_config. build_plan = self . flag ( "build-plan" ) ;
725709 build_config. unit_graph = self . flag ( "unit-graph" ) ;
726710 build_config. future_incompat_report = self . flag ( "future-incompat-report" ) ;
0 commit comments