@@ -158,24 +158,6 @@ impl<'a> Toolchain<'a> {
158
158
== Some ( true )
159
159
}
160
160
161
- // Custom and Distributable. Installed only.
162
- fn set_env ( & self , cmd : & mut Command ) {
163
- self . set_ldpath ( cmd) ;
164
-
165
- // Because rustup and cargo use slightly different
166
- // definitions of cargo home (rustup doesn't read HOME on
167
- // windows), we must set it here to ensure cargo and
168
- // rustup agree.
169
- if let Ok ( cargo_home) = utils:: cargo_home ( ) {
170
- cmd. env ( "CARGO_HOME" , & cargo_home) ;
171
- }
172
-
173
- env_var:: inc ( "RUST_RECURSION_COUNT" , cmd) ;
174
-
175
- cmd. env ( "RUSTUP_TOOLCHAIN" , & self . name ) ;
176
- cmd. env ( "RUSTUP_HOME" , & self . cfg . rustup_dir ) ;
177
- }
178
-
179
161
// Custom and Distributable. Installed only.
180
162
pub fn set_ldpath ( & self , cmd : & mut Command ) {
181
163
let mut new_path = vec ! [ self . path. join( "lib" ) ] ;
@@ -358,9 +340,26 @@ impl<'a> InstalledCommonToolchain<'a> {
358
340
Path :: new ( & binary)
359
341
} ;
360
342
let mut cmd = Command :: new ( & path) ;
361
- self . 0 . set_env ( & mut cmd) ;
343
+ self . set_env ( & mut cmd) ;
362
344
Ok ( cmd)
363
345
}
346
+
347
+ fn set_env ( & self , cmd : & mut Command ) {
348
+ self . 0 . set_ldpath ( cmd) ;
349
+
350
+ // Because rustup and cargo use slightly different
351
+ // definitions of cargo home (rustup doesn't read HOME on
352
+ // windows), we must set it here to ensure cargo and
353
+ // rustup agree.
354
+ if let Ok ( cargo_home) = utils:: cargo_home ( ) {
355
+ cmd. env ( "CARGO_HOME" , & cargo_home) ;
356
+ }
357
+
358
+ env_var:: inc ( "RUST_RECURSION_COUNT" , cmd) ;
359
+
360
+ cmd. env ( "RUSTUP_TOOLCHAIN" , & self . 0 . name ) ;
361
+ cmd. env ( "RUSTUP_HOME" , & self . 0 . cfg . rustup_dir ) ;
362
+ }
364
363
}
365
364
366
365
/// Newtype to facilitate splitting out custom-toolchain specific code.
@@ -494,9 +493,7 @@ impl<'a> DistributableToolchain<'a> {
494
493
if !self . 0 . exists ( ) {
495
494
return Err ( ErrorKind :: ToolchainNotInstalled ( self . 0 . name . to_owned ( ) ) . into ( ) ) ;
496
495
}
497
- if !primary_toolchain. exists ( ) {
498
- return Err ( ErrorKind :: ToolchainNotInstalled ( primary_toolchain. name . to_owned ( ) ) . into ( ) ) ;
499
- }
496
+ let installed_primary = primary_toolchain. as_installed_common ( ) ?;
500
497
501
498
let src_file = self . 0 . path . join ( "bin" ) . join ( format ! ( "cargo{}" , EXE_SUFFIX ) ) ;
502
499
@@ -528,7 +525,7 @@ impl<'a> DistributableToolchain<'a> {
528
525
src_file
529
526
} ;
530
527
let mut cmd = Command :: new ( exe_path) ;
531
- primary_toolchain . set_env ( & mut cmd) ; // set up the environment to match rustc, not cargo
528
+ installed_primary . set_env ( & mut cmd) ; // set up the environment to match rustc, not cargo
532
529
cmd. env ( "RUSTUP_TOOLCHAIN" , & primary_toolchain. name ) ;
533
530
Ok ( cmd)
534
531
}
0 commit comments