@@ -332,35 +332,36 @@ impl<'a> Toolchain<'a> {
332
332
pub ( crate ) fn command ( & self , binary : & str ) -> anyhow:: Result < Command > {
333
333
// Should push the cargo fallback into a custom toolchain type? And then
334
334
// perhaps a trait that create command layers on?
335
- if let Some ( cmd) = self . maybe_do_cargo_fallback ( binary) ? {
336
- info ! ( "`cargo` is unavailable for the active toolchain" ) ;
337
- info ! ( "falling back to {:?}" , cmd. get_program( ) ) ;
338
- return Ok ( cmd) ;
339
- } else if let Some ( cmd) = self . maybe_do_rust_analyzer_fallback ( binary) ? {
340
- info ! ( "`rust-analyzer` is unavailable for the active toolchain" ) ;
341
- info ! ( "falling back to {:?}" , cmd. get_program( ) ) ;
342
- return Ok ( cmd) ;
335
+ if let "cargo" | "cargo.exe" = binary {
336
+ if let Some ( cmd) = self . maybe_do_cargo_fallback ( ) ? {
337
+ info ! ( "`cargo` is unavailable for the active toolchain" ) ;
338
+ info ! ( "falling back to {:?}" , cmd. get_program( ) ) ;
339
+ return Ok ( cmd) ;
340
+ }
341
+ } else if let "rust-analyzer" | "rust-analyzer.exe" = binary {
342
+ if let Some ( cmd) = self . maybe_do_rust_analyzer_fallback ( binary) ? {
343
+ info ! ( "`rust-analyzer` is unavailable for the active toolchain" ) ;
344
+ info ! ( "falling back to {:?}" , cmd. get_program( ) ) ;
345
+ return Ok ( cmd) ;
346
+ }
343
347
}
344
348
345
349
self . create_command ( binary)
346
350
}
347
351
348
352
// Custom toolchains don't have cargo, so here we detect that situation and
349
353
// try to find a different cargo.
350
- fn maybe_do_cargo_fallback ( & self , binary : & str ) -> anyhow:: Result < Option < Command > > {
354
+ fn maybe_do_cargo_fallback ( & self ) -> anyhow:: Result < Option < Command > > {
351
355
if let LocalToolchainName :: Named ( ToolchainName :: Official ( _) ) = self . name ( ) {
352
356
return Ok ( None ) ;
353
- } else if binary != "cargo" && binary != "cargo.exe" {
354
- return Ok ( None ) ;
355
357
}
356
358
357
- let cargo_path = self . binary_file ( "cargo" ) ;
358
-
359
359
// breadcrumb in case of regression: we used to get the cargo path and
360
360
// cargo.exe path separately, not using the binary_file helper. This may
361
361
// matter if calling a binary with some personality that allows .exe and
362
362
// not .exe to coexist (e.g. wine) - but that's not something we aim to
363
363
// support : the host should always be correct.
364
+ let cargo_path = self . binary_file ( "cargo" ) ;
364
365
if cargo_path. exists ( ) {
365
366
return Ok ( None ) ;
366
367
}
@@ -391,9 +392,7 @@ impl<'a> Toolchain<'a> {
391
392
/// - <https://github.com/rust-lang/rustup/issues/3299>
392
393
/// - <https://github.com/rust-lang/rustup/issues/3846>
393
394
fn maybe_do_rust_analyzer_fallback ( & self , binary : & str ) -> anyhow:: Result < Option < Command > > {
394
- if binary != "rust-analyzer" && binary != "rust-analyzer.exe"
395
- || self . binary_file ( "rust-analyzer" ) . exists ( )
396
- {
395
+ if self . binary_file ( "rust-analyzer" ) . exists ( ) {
397
396
return Ok ( None ) ;
398
397
}
399
398
0 commit comments