@@ -23,10 +23,9 @@ use crate::conv::{map_rust_diagnostic_to_lsp, MappedRustDiagnostic};
2323pub use crate :: conv:: url_from_path_with_drive_lowercasing;
2424
2525#[ derive( Clone , Debug ) ]
26- pub struct FlycheckConfig {
27- pub command : String ,
28- pub all_targets : bool ,
29- pub extra_args : Vec < String > ,
26+ pub enum FlycheckConfig {
27+ CargoCommand { command : String , all_targets : bool , extra_args : Vec < String > } ,
28+ CustomCommand { command : String , args : Vec < String > } ,
3029}
3130
3231/// Flycheck wraps the shared state and communication machinery used for
@@ -215,18 +214,25 @@ impl FlycheckThread {
215214 self . message_recv = never ( ) ;
216215 self . check_process = None ;
217216
218- let cmd = {
219- let mut cmd = Command :: new ( cargo_binary ( ) ) ;
220- cmd. arg ( & self . config . command ) ;
221- cmd. args ( & [ "--workspace" , "--message-format=json" , "--manifest-path" ] ) ;
222- cmd. arg ( self . workspace_root . join ( "Cargo.toml" ) ) ;
223- if self . config . all_targets {
224- cmd. arg ( "--all-targets" ) ;
217+ let mut cmd = match & self . config {
218+ FlycheckConfig :: CargoCommand { command, all_targets, extra_args } => {
219+ let mut cmd = Command :: new ( cargo_binary ( ) ) ;
220+ cmd. arg ( command) ;
221+ cmd. args ( & [ "--workspace" , "--message-format=json" , "--manifest-path" ] ) ;
222+ cmd. arg ( self . workspace_root . join ( "Cargo.toml" ) ) ;
223+ if * all_targets {
224+ cmd. arg ( "--all-targets" ) ;
225+ }
226+ cmd. args ( extra_args) ;
227+ cmd
228+ }
229+ FlycheckConfig :: CustomCommand { command, args } => {
230+ let mut cmd = Command :: new ( command) ;
231+ cmd. args ( args) ;
232+ cmd
225233 }
226- cmd. args ( self . config . extra_args . iter ( ) ) ;
227- cmd. current_dir ( & self . workspace_root ) ;
228- cmd
229234 } ;
235+ cmd. current_dir ( & self . workspace_root ) ;
230236
231237 let ( message_send, message_recv) = unbounded ( ) ;
232238 self . message_recv = message_recv;
0 commit comments