@@ -54,6 +54,7 @@ use std::collections::{BTreeMap, HashMap, HashSet};
54
54
use std:: fmt:: Write as _;
55
55
use std:: io;
56
56
use std:: marker;
57
+ use std:: path:: PathBuf ;
57
58
use std:: sync:: Arc ;
58
59
use std:: thread:: { self , Scope } ;
59
60
use std:: time:: Duration ;
@@ -769,7 +770,11 @@ impl<'cfg> DrainState<'cfg> {
769
770
self . tokens . extend ( rustc_tokens) ;
770
771
}
771
772
self . to_send_clients . remove ( & id) ;
772
- self . report_warning_count ( cx. bcx . config , id) ;
773
+ self . report_warning_count (
774
+ cx. bcx . config ,
775
+ id,
776
+ & cx. bcx . rustc ( ) . workspace_wrapper ,
777
+ ) ;
773
778
self . active . remove ( & id) . unwrap ( )
774
779
}
775
780
// ... otherwise if it hasn't finished we leave it
@@ -1206,7 +1211,12 @@ impl<'cfg> DrainState<'cfg> {
1206
1211
}
1207
1212
1208
1213
/// Displays a final report of the warnings emitted by a particular job.
1209
- fn report_warning_count ( & mut self , config : & Config , id : JobId ) {
1214
+ fn report_warning_count (
1215
+ & mut self ,
1216
+ config : & Config ,
1217
+ id : JobId ,
1218
+ rustc_workspace_wrapper : & Option < PathBuf > ,
1219
+ ) {
1210
1220
let count = match self . warning_count . remove ( & id) {
1211
1221
// An error could add an entry for a `Unit`
1212
1222
// with 0 warnings but having fixable
@@ -1239,7 +1249,19 @@ impl<'cfg> DrainState<'cfg> {
1239
1249
if let FixableWarnings :: Positive ( fixable) = count. fixable {
1240
1250
// `cargo fix` doesnt have an option for custom builds
1241
1251
if !unit. target . is_custom_build ( ) {
1242
- let mut command = {
1252
+ // To make sure the correct command is shown for `clippy` we
1253
+ // check if `RUSTC_WORKSPACE_WRAPPER` is set and pointing towards
1254
+ // `clippy-driver`.
1255
+ let command = match rustc_workspace_wrapper {
1256
+ #[ cfg( windows) ]
1257
+ Some ( wrapper) if wrapper. ends_with ( "clippy-driver.exe" ) => {
1258
+ "cargo clippy --fix"
1259
+ }
1260
+ #[ cfg( not( windows) ) ]
1261
+ Some ( wrapper) if wrapper. ends_with ( "clippy-driver" ) => "cargo clippy --fix" ,
1262
+ _ => "cargo fix" ,
1263
+ } ;
1264
+ let mut args = {
1243
1265
let named = unit. target . description_named ( ) ;
1244
1266
// if its a lib we need to add the package to fix
1245
1267
if unit. target . is_lib ( ) {
@@ -1251,16 +1273,16 @@ impl<'cfg> DrainState<'cfg> {
1251
1273
if unit. mode . is_rustc_test ( )
1252
1274
&& !( unit. target . is_test ( ) || unit. target . is_bench ( ) )
1253
1275
{
1254
- command . push_str ( " --tests" ) ;
1276
+ args . push_str ( " --tests" ) ;
1255
1277
}
1256
1278
let mut suggestions = format ! ( "{} suggestion" , fixable) ;
1257
1279
if fixable > 1 {
1258
1280
suggestions. push_str ( "s" )
1259
1281
}
1260
1282
drop ( write ! (
1261
1283
message,
1262
- " (run `cargo fix --{}` to apply {})" ,
1263
- command, suggestions
1284
+ " (run `{} --{}` to apply {})" ,
1285
+ command, args , suggestions
1264
1286
) )
1265
1287
}
1266
1288
}
0 commit comments