@@ -642,12 +642,12 @@ impl Config {
642
642
let llvm_assertions = llvm_assertions. unwrap_or ( false ) ;
643
643
let mut target_config = HashMap :: new ( ) ;
644
644
let mut channel = "dev" . to_string ( ) ;
645
+
646
+ let out = flags_build_dir. or_else ( || build_build_dir. map ( PathBuf :: from) ) ;
645
647
let out = if cfg ! ( test) {
646
- test_build_dir ( )
648
+ out . expect ( "--build-dir has to be specified in tests" )
647
649
} else {
648
- flags_build_dir
649
- . or_else ( || build_build_dir. map ( PathBuf :: from) )
650
- . unwrap_or_else ( || PathBuf :: from ( "build" ) )
650
+ out. unwrap_or_else ( || PathBuf :: from ( "build" ) )
651
651
} ;
652
652
653
653
// NOTE: Bootstrap spawns various commands with different working directories.
@@ -2490,22 +2490,3 @@ fn find_correct_section_for_field(field_name: &str) -> Vec<WouldBeValidFor> {
2490
2490
} )
2491
2491
. collect ( )
2492
2492
}
2493
-
2494
- /// Resolve the build directory used for tests.
2495
- ///
2496
- /// - When tests are run through bootstrap (`x.py test`), the build system
2497
- /// sets `CARGO_TARGET_DIR`, so we can trust and use it here.
2498
- /// - When tests are run directly with cargo test, `CARGO_TARGET_DIR` will
2499
- /// not be set. In that case we fall back to resolving relative to
2500
- /// `CARGO_MANIFEST_DIR`, by walking two parents up and appending `build`.
2501
- fn test_build_dir ( ) -> PathBuf {
2502
- env:: var_os ( "CARGO_TARGET_DIR" )
2503
- . map ( |value| Path :: new ( & value) . parent ( ) . unwrap ( ) . to_path_buf ( ) )
2504
- . unwrap_or_else ( || {
2505
- let base = option_env ! ( "CARGO_MANIFEST_DIR" )
2506
- . map ( PathBuf :: from)
2507
- . unwrap_or_else ( || std:: env:: current_dir ( ) . expect ( "failed to get current dir" ) ) ;
2508
-
2509
- base. ancestors ( ) . nth ( 2 ) . unwrap_or_else ( || Path :: new ( "." ) ) . join ( "build" )
2510
- } )
2511
- }
0 commit comments