@@ -9,6 +9,7 @@ use std::process::{Child, Command, ExitStatus, Output, Stdio};
9
9
use std:: sync:: Arc ;
10
10
use std:: { env, iter, str} ;
11
11
12
+ use build_helper:: fs:: remove_and_create_dir_all;
12
13
use camino:: { Utf8Path , Utf8PathBuf } ;
13
14
use colored:: Colorize ;
14
15
use regex:: { Captures , Regex } ;
@@ -207,12 +208,6 @@ pub fn compute_stamp_hash(config: &Config) -> String {
207
208
format ! ( "{:x}" , hash. finish( ) )
208
209
}
209
210
210
- fn remove_and_create_dir_all ( path : & Utf8Path ) {
211
- let path = path. as_std_path ( ) ;
212
- let _ = fs:: remove_dir_all ( path) ;
213
- fs:: create_dir_all ( path) . unwrap ( ) ;
214
- }
215
-
216
211
#[ derive( Copy , Clone , Debug ) ]
217
212
struct TestCx < ' test > {
218
213
config : & ' test Config ,
@@ -523,7 +518,8 @@ impl<'test> TestCx<'test> {
523
518
let mut rustc = Command :: new ( & self . config . rustc_path ) ;
524
519
525
520
let out_dir = self . output_base_name ( ) . with_extension ( "pretty-out" ) ;
526
- remove_and_create_dir_all ( & out_dir) ;
521
+ remove_and_create_dir_all ( & out_dir)
522
+ . expect ( "Failed to remove and recreate output directory" ) ;
527
523
528
524
let target = if self . props . force_host { & * self . config . host } else { & * self . config . target } ;
529
525
@@ -1098,13 +1094,16 @@ impl<'test> TestCx<'test> {
1098
1094
let aux_dir = self . aux_output_dir_name ( ) ;
1099
1095
1100
1096
if !self . props . aux . builds . is_empty ( ) {
1101
- remove_and_create_dir_all ( & aux_dir) ;
1097
+ remove_and_create_dir_all ( & aux_dir)
1098
+ . expect ( "Failed to remove and recreate output directory" ) ;
1102
1099
}
1103
1100
1104
1101
if !self . props . aux . bins . is_empty ( ) {
1105
1102
let aux_bin_dir = self . aux_bin_output_dir_name ( ) ;
1106
- remove_and_create_dir_all ( & aux_dir) ;
1107
- remove_and_create_dir_all ( & aux_bin_dir) ;
1103
+ remove_and_create_dir_all ( & aux_dir)
1104
+ . expect ( "Failed to remove and recreate output directory" ) ;
1105
+ remove_and_create_dir_all ( & aux_bin_dir)
1106
+ . expect ( "Failed to remove and recreate output directory" ) ;
1108
1107
}
1109
1108
1110
1109
aux_dir
@@ -1509,7 +1508,8 @@ impl<'test> TestCx<'test> {
1509
1508
1510
1509
let set_mir_dump_dir = |rustc : & mut Command | {
1511
1510
let mir_dump_dir = self . get_mir_dump_dir ( ) ;
1512
- remove_and_create_dir_all ( & mir_dump_dir) ;
1511
+ remove_and_create_dir_all ( & mir_dump_dir)
1512
+ . expect ( "Failed to remove and recreate output directory" ) ;
1513
1513
let mut dir_opt = "-Zdump-mir-dir=" . to_string ( ) ;
1514
1514
dir_opt. push_str ( mir_dump_dir. as_str ( ) ) ;
1515
1515
debug ! ( "dir_opt: {:?}" , dir_opt) ;
@@ -1969,7 +1969,8 @@ impl<'test> TestCx<'test> {
1969
1969
let suffix =
1970
1970
self . safe_revision ( ) . map_or ( "nightly" . into ( ) , |path| path. to_owned ( ) + "-nightly" ) ;
1971
1971
let compare_dir = output_base_dir ( self . config , self . testpaths , Some ( & suffix) ) ;
1972
- remove_and_create_dir_all ( & compare_dir) ;
1972
+ remove_and_create_dir_all ( & compare_dir)
1973
+ . expect ( "Failed to remove and recreate output directory" ) ;
1973
1974
1974
1975
// We need to create a new struct for the lifetimes on `config` to work.
1975
1976
let new_rustdoc = TestCx {
0 commit comments