@@ -487,26 +487,18 @@ impl Cfg {
487
487
}
488
488
489
489
fn find_override_config ( & self , path : & Path ) -> Result < Option < ( OverrideCfg , OverrideReason ) > > {
490
- let mut override_ = None :: < ( OverrideFile , OverrideReason ) > ;
491
-
492
- let mut update_override = |file, reason| {
493
- if let Some ( ( file1, reason1) ) = & mut override_ {
494
- if file1. has_toolchain ( ) {
495
- // Update the reason only if the override file has a toolchain.
496
- * reason1 = reason
497
- }
498
- file1. merge ( file) ;
499
- } else {
500
- override_ = Some ( ( file, reason) )
501
- } ;
502
- } ;
490
+ let mut override_ = None ;
503
491
504
492
// Check for all possible toolchain overrides below...
505
493
// See: <https://rust-lang.github.io/rustup/overrides.html>
506
494
507
495
// 1. Check toolchain override from command
508
496
if let Some ( ref name) = self . toolchain_override {
509
- update_override ( name. to_string ( ) . into ( ) , OverrideReason :: CommandLine ) ;
497
+ update_override (
498
+ & mut override_,
499
+ name. to_string ( ) . into ( ) ,
500
+ OverrideReason :: CommandLine ,
501
+ ) ;
510
502
}
511
503
512
504
// 2. Check RUSTUP_TOOLCHAIN
@@ -515,15 +507,19 @@ impl Cfg {
515
507
// custom, distributable, and absolute path toolchains otherwise
516
508
// rustup's export of a RUSTUP_TOOLCHAIN when running a process will
517
509
// error when a nested rustup invocation occurs
518
- update_override ( name. to_string ( ) . into ( ) , OverrideReason :: Environment ) ;
510
+ update_override (
511
+ & mut override_,
512
+ name. to_string ( ) . into ( ) ,
513
+ OverrideReason :: Environment ,
514
+ ) ;
519
515
}
520
516
521
517
// 3. walk up the directory tree from 'path' looking for either the
522
518
// directory in override database, or
523
519
// 4. a `rust-toolchain` file.
524
520
self . settings_file . with ( |s| {
525
521
if let Some ( ( file, reason) ) = self . find_override_from_dir_walk ( path, s) ? {
526
- update_override ( file, reason) ;
522
+ update_override ( & mut override_ , file, reason) ;
527
523
}
528
524
Ok ( ( ) )
529
525
} ) ?;
@@ -1006,6 +1002,22 @@ impl Cfg {
1006
1002
}
1007
1003
}
1008
1004
1005
+ fn update_override (
1006
+ override_ : & mut Option < ( OverrideFile , OverrideReason ) > ,
1007
+ file : OverrideFile ,
1008
+ reason : OverrideReason ,
1009
+ ) {
1010
+ if let Some ( ( file1, reason1) ) = override_ {
1011
+ if file1. has_toolchain ( ) {
1012
+ // Update the reason only if the override file has a toolchain.
1013
+ * reason1 = reason
1014
+ }
1015
+ file1. merge ( file) ;
1016
+ } else {
1017
+ * override_ = Some ( ( file, reason) )
1018
+ } ;
1019
+ }
1020
+
1009
1021
fn get_default_host_triple ( s : & Settings ) -> dist:: TargetTriple {
1010
1022
s. default_host_triple
1011
1023
. as_ref ( )
0 commit comments