@@ -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 ;
@@ -799,7 +800,11 @@ impl<'cfg> DrainState<'cfg> {
799
800
self . tokens . extend ( rustc_tokens) ;
800
801
}
801
802
self . to_send_clients . remove ( & id) ;
802
- self . report_warning_count ( cx. bcx . config , id) ;
803
+ self . report_warning_count (
804
+ cx. bcx . config ,
805
+ id,
806
+ & cx. bcx . rustc ( ) . workspace_wrapper ,
807
+ ) ;
803
808
self . active . remove ( & id) . unwrap ( )
804
809
}
805
810
// ... otherwise if it hasn't finished we leave it
@@ -1243,7 +1248,12 @@ impl<'cfg> DrainState<'cfg> {
1243
1248
}
1244
1249
1245
1250
/// Displays a final report of the warnings emitted by a particular job.
1246
- fn report_warning_count ( & mut self , config : & Config , id : JobId ) {
1251
+ fn report_warning_count (
1252
+ & mut self ,
1253
+ config : & Config ,
1254
+ id : JobId ,
1255
+ rustc_workspace_wrapper : & Option < PathBuf > ,
1256
+ ) {
1247
1257
let count = match self . warning_count . remove ( & id) {
1248
1258
// An error could add an entry for a `Unit`
1249
1259
// with 0 warnings but having fixable
@@ -1276,7 +1286,16 @@ impl<'cfg> DrainState<'cfg> {
1276
1286
if let FixableWarnings :: Positive ( fixable) = count. fixable {
1277
1287
// `cargo fix` doesnt have an option for custom builds
1278
1288
if !unit. target . is_custom_build ( ) {
1279
- let mut command = {
1289
+ // To make sure the correct command is shown for `clippy` we
1290
+ // check if `RUSTC_WORKSPACE_WRAPPER` is set and pointing towards
1291
+ // `clippy-driver`.
1292
+ let clippy = std:: ffi:: OsStr :: new ( "clippy-driver" ) ;
1293
+ let command = match rustc_workspace_wrapper. as_ref ( ) . and_then ( |x| x. file_stem ( ) )
1294
+ {
1295
+ Some ( wrapper) if wrapper == clippy => "cargo clippy --fix" ,
1296
+ _ => "cargo fix" ,
1297
+ } ;
1298
+ let mut args = {
1280
1299
let named = unit. target . description_named ( ) ;
1281
1300
// if its a lib we need to add the package to fix
1282
1301
if unit. target . is_lib ( ) {
@@ -1288,16 +1307,15 @@ impl<'cfg> DrainState<'cfg> {
1288
1307
if unit. mode . is_rustc_test ( )
1289
1308
&& !( unit. target . is_test ( ) || unit. target . is_bench ( ) )
1290
1309
{
1291
- command . push_str ( " --tests" ) ;
1310
+ args . push_str ( " --tests" ) ;
1292
1311
}
1293
1312
let mut suggestions = format ! ( "{} suggestion" , fixable) ;
1294
1313
if fixable > 1 {
1295
1314
suggestions. push_str ( "s" )
1296
1315
}
1297
1316
drop ( write ! (
1298
1317
message,
1299
- " (run `cargo fix --{}` to apply {})" ,
1300
- command, suggestions
1318
+ " (run `{command} --{args}` to apply {suggestions})"
1301
1319
) )
1302
1320
}
1303
1321
}
0 commit comments