@@ -54,6 +54,7 @@ use std::collections::{BTreeMap, HashMap, HashSet};
5454use std:: fmt:: Write as _;
5555use std:: io;
5656use std:: marker;
57+ use std:: path:: PathBuf ;
5758use std:: sync:: Arc ;
5859use std:: thread:: { self , Scope } ;
5960use std:: time:: Duration ;
@@ -799,7 +800,11 @@ impl<'cfg> DrainState<'cfg> {
799800 self . tokens . extend ( rustc_tokens) ;
800801 }
801802 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+ ) ;
803808 self . active . remove ( & id) . unwrap ( )
804809 }
805810 // ... otherwise if it hasn't finished we leave it
@@ -1243,7 +1248,12 @@ impl<'cfg> DrainState<'cfg> {
12431248 }
12441249
12451250 /// 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+ ) {
12471257 let count = match self . warning_count . remove ( & id) {
12481258 // An error could add an entry for a `Unit`
12491259 // with 0 warnings but having fixable
@@ -1276,7 +1286,16 @@ impl<'cfg> DrainState<'cfg> {
12761286 if let FixableWarnings :: Positive ( fixable) = count. fixable {
12771287 // `cargo fix` doesnt have an option for custom builds
12781288 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 = {
12801299 let named = unit. target . description_named ( ) ;
12811300 // if its a lib we need to add the package to fix
12821301 if unit. target . is_lib ( ) {
@@ -1288,16 +1307,15 @@ impl<'cfg> DrainState<'cfg> {
12881307 if unit. mode . is_rustc_test ( )
12891308 && !( unit. target . is_test ( ) || unit. target . is_bench ( ) )
12901309 {
1291- command . push_str ( " --tests" ) ;
1310+ args . push_str ( " --tests" ) ;
12921311 }
12931312 let mut suggestions = format ! ( "{} suggestion" , fixable) ;
12941313 if fixable > 1 {
12951314 suggestions. push_str ( "s" )
12961315 }
12971316 drop ( write ! (
12981317 message,
1299- " (run `cargo fix --{}` to apply {})" ,
1300- command, suggestions
1318+ " (run `{command} --{args}` to apply {suggestions})"
13011319 ) )
13021320 }
13031321 }
0 commit comments