@@ -172,14 +172,11 @@ impl fmt::Debug for ProjectWorkspace {
172172
173173fn get_toolchain_version (
174174 current_dir : & AbsPath ,
175- sysroot : Option < & Sysroot > ,
176- tool : Tool ,
175+ mut cmd : Command ,
177176 extra_env : & FxHashMap < String , String > ,
178177 prefix : & str ,
179178) -> Result < Option < Version > , anyhow:: Error > {
180179 let cargo_version = utf8_stdout ( {
181- let mut cmd = Command :: new ( tool. path ( ) ) ;
182- Sysroot :: set_rustup_toolchain_env ( & mut cmd, sysroot) ;
183180 cmd. envs ( extra_env) ;
184181 cmd. arg ( "--version" ) . current_dir ( current_dir) ;
185182 cmd
@@ -300,8 +297,11 @@ impl ProjectWorkspace {
300297
301298 let toolchain = get_toolchain_version (
302299 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+ } ,
305305 & config. extra_env ,
306306 "cargo " ,
307307 ) ?;
@@ -386,8 +386,7 @@ impl ProjectWorkspace {
386386 let data_layout_config = RustcDataLayoutConfig :: Rustc ( sysroot_ref) ;
387387 let toolchain = match get_toolchain_version (
388388 project_json. path ( ) ,
389- sysroot_ref,
390- toolchain:: Tool :: Rustc ,
389+ Sysroot :: rustc ( sysroot_ref) ,
391390 extra_env,
392391 "rustc " ,
393392 ) {
@@ -436,8 +435,7 @@ impl ProjectWorkspace {
436435 let sysroot_ref = sysroot. as_ref ( ) . ok ( ) ;
437436 let toolchain = match get_toolchain_version (
438437 dir,
439- sysroot_ref,
440- toolchain:: Tool :: Rustc ,
438+ Sysroot :: rustc ( sysroot_ref) ,
441439 & config. extra_env ,
442440 "rustc " ,
443441 ) {
0 commit comments