@@ -483,10 +483,8 @@ fn try_main() -> MainResult<i32> {
483
483
#[ cfg( unix) ]
484
484
{
485
485
if action. execute {
486
- let cmd_name = action. build_kind . exec_command ( ) ;
487
- info ! ( "running `cargo {}`" , cmd_name) ;
488
486
let run_quietly = !action. cargo_output ;
489
- let mut cmd = action. cargo ( cmd_name , & args. script_args , run_quietly) ?;
487
+ let mut cmd = action. cargo ( action . build_kind , & args. script_args , run_quietly) ?;
490
488
491
489
let err = cmd. exec ( ) ;
492
490
Err ( MainError :: from ( err) )
@@ -716,9 +714,14 @@ impl InputAction {
716
714
self . pkg_path . join ( "Cargo.toml" )
717
715
}
718
716
719
- fn cargo ( & self , cmd : & str , script_args : & [ String ] , run_quietly : bool ) -> MainResult < Command > {
717
+ fn cargo (
718
+ & self ,
719
+ build_kind : BuildKind ,
720
+ script_args : & [ String ] ,
721
+ run_quietly : bool ,
722
+ ) -> MainResult < Command > {
720
723
cargo (
721
- cmd ,
724
+ build_kind ,
722
725
& * self . manifest_path ( ) . to_string_lossy ( ) ,
723
726
self . toolchain_version . as_deref ( ) ,
724
727
& self . metadata ,
@@ -803,7 +806,7 @@ fn decide_action_for(
803
806
Input :: File ( _, path, _, mtime) => {
804
807
( Some ( path. to_string_lossy ( ) . into_owned ( ) ) , Some ( mtime) )
805
808
}
806
- _ => ( None , None )
809
+ _ => ( None , None ) ,
807
810
} ;
808
811
PackageMetadata {
809
812
path,
@@ -1162,7 +1165,7 @@ where
1162
1165
Constructs a Cargo command that runs on the script package.
1163
1166
*/
1164
1167
fn cargo (
1165
- cmd_name : & str ,
1168
+ build_kind : BuildKind ,
1166
1169
manifest : & str ,
1167
1170
maybe_toolchain_version : Option < & str > ,
1168
1171
meta : & PackageMetadata ,
@@ -1173,9 +1176,9 @@ fn cargo(
1173
1176
if let Some ( toolchain_version) = maybe_toolchain_version {
1174
1177
cmd. arg ( format ! ( "+{}" , toolchain_version) ) ;
1175
1178
}
1176
- cmd. arg ( cmd_name ) ;
1179
+ cmd. arg ( build_kind . exec_command ( ) ) ;
1177
1180
1178
- if cmd_name == "run" && run_quietly {
1181
+ if matches ! ( build_kind , BuildKind :: Normal ) && run_quietly {
1179
1182
cmd. arg ( "-q" ) ;
1180
1183
}
1181
1184
@@ -1190,15 +1193,15 @@ fn cargo(
1190
1193
cmd. arg ( cargo_target_dir) ;
1191
1194
1192
1195
// Block `--release` on `bench`.
1193
- if !meta. debug && cmd_name != "bench" {
1196
+ if !meta. debug && ! matches ! ( build_kind , BuildKind :: Bench ) {
1194
1197
cmd. arg ( "--release" ) ;
1195
1198
}
1196
1199
1197
1200
if let Some ( ref features) = meta. features {
1198
1201
cmd. arg ( "--features" ) . arg ( features) ;
1199
1202
}
1200
1203
1201
- if cmd_name == "run" && !script_args. is_empty ( ) {
1204
+ if matches ! ( build_kind , BuildKind :: Normal ) && !script_args. is_empty ( ) {
1202
1205
cmd. arg ( "--" ) ;
1203
1206
cmd. args ( script_args. iter ( ) ) ;
1204
1207
}
0 commit comments