@@ -172,14 +172,11 @@ impl fmt::Debug for ProjectWorkspace {
172
172
173
173
fn get_toolchain_version (
174
174
current_dir : & AbsPath ,
175
- sysroot : Option < & Sysroot > ,
176
- tool : Tool ,
175
+ mut cmd : Command ,
177
176
extra_env : & FxHashMap < String , String > ,
178
177
prefix : & str ,
179
178
) -> Result < Option < Version > , anyhow:: Error > {
180
179
let cargo_version = utf8_stdout ( {
181
- let mut cmd = Command :: new ( tool. path ( ) ) ;
182
- Sysroot :: set_rustup_toolchain_env ( & mut cmd, sysroot) ;
183
180
cmd. envs ( extra_env) ;
184
181
cmd. arg ( "--version" ) . current_dir ( current_dir) ;
185
182
cmd
@@ -300,8 +297,11 @@ impl ProjectWorkspace {
300
297
301
298
let toolchain = get_toolchain_version (
302
299
cargo_toml. parent ( ) ,
303
- sysroot_ref,
304
- toolchain:: Tool :: Cargo ,
300
+ {
301
+ let mut cmd = Command :: new ( toolchain:: Tool :: Cargo . path ( ) ) ;
302
+ Sysroot :: set_rustup_toolchain_env ( & mut cmd, sysroot_ref) ;
303
+ cmd
304
+ } ,
305
305
& config. extra_env ,
306
306
"cargo " ,
307
307
) ?;
@@ -386,8 +386,7 @@ impl ProjectWorkspace {
386
386
let data_layout_config = RustcDataLayoutConfig :: Rustc ( sysroot_ref) ;
387
387
let toolchain = match get_toolchain_version (
388
388
project_json. path ( ) ,
389
- sysroot_ref,
390
- toolchain:: Tool :: Rustc ,
389
+ Sysroot :: rustc ( sysroot_ref) ,
391
390
extra_env,
392
391
"rustc " ,
393
392
) {
@@ -436,8 +435,7 @@ impl ProjectWorkspace {
436
435
let sysroot_ref = sysroot. as_ref ( ) . ok ( ) ;
437
436
let toolchain = match get_toolchain_version (
438
437
dir,
439
- sysroot_ref,
440
- toolchain:: Tool :: Rustc ,
438
+ Sysroot :: rustc ( sysroot_ref) ,
441
439
& config. extra_env ,
442
440
"rustc " ,
443
441
) {
0 commit comments