@@ -198,6 +198,11 @@ pub fn compute_stamp_hash(config: &Config) -> String {
198
198
format ! ( "{:x}" , hash. finish( ) )
199
199
}
200
200
201
+ fn remove_and_create_dir_all ( path : & Path ) {
202
+ let _ = fs:: remove_dir_all ( path) ;
203
+ fs:: create_dir_all ( path) . unwrap ( ) ;
204
+ }
205
+
201
206
#[ derive( Copy , Clone ) ]
202
207
struct TestCx < ' test > {
203
208
config : & ' test Config ,
@@ -998,8 +1003,7 @@ impl<'test> TestCx<'test> {
998
1003
let mut rustc = Command :: new ( & self . config . rustc_path ) ;
999
1004
1000
1005
let out_dir = self . output_base_name ( ) . with_extension ( "pretty-out" ) ;
1001
- let _ = fs:: remove_dir_all ( & out_dir) ;
1002
- create_dir_all ( & out_dir) . unwrap ( ) ;
1006
+ remove_and_create_dir_all ( & out_dir) ;
1003
1007
1004
1008
let target = if self . props . force_host { & * self . config . host } else { & * self . config . target } ;
1005
1009
@@ -2094,14 +2098,12 @@ impl<'test> TestCx<'test> {
2094
2098
let aux_dir = self . aux_output_dir_name ( ) ;
2095
2099
2096
2100
if !self . props . aux_builds . is_empty ( ) {
2097
- let _ = fs:: remove_dir_all ( & aux_dir) ;
2098
- create_dir_all ( & aux_dir) . unwrap ( ) ;
2101
+ remove_and_create_dir_all ( & aux_dir) ;
2099
2102
}
2100
2103
2101
2104
if !self . props . aux_bins . is_empty ( ) {
2102
2105
let aux_bin_dir = self . aux_bin_output_dir_name ( ) ;
2103
- let _ = fs:: remove_dir_all ( & aux_bin_dir) ;
2104
- create_dir_all ( & aux_bin_dir) . unwrap ( ) ;
2106
+ remove_and_create_dir_all ( & aux_bin_dir) ;
2105
2107
}
2106
2108
2107
2109
aux_dir
@@ -2469,8 +2471,7 @@ impl<'test> TestCx<'test> {
2469
2471
}
2470
2472
2471
2473
let mir_dump_dir = self . get_mir_dump_dir ( ) ;
2472
- let _ = fs:: remove_dir_all ( & mir_dump_dir) ;
2473
- create_dir_all ( mir_dump_dir. as_path ( ) ) . unwrap ( ) ;
2474
+ remove_and_create_dir_all ( & mir_dump_dir) ;
2474
2475
let mut dir_opt = "-Zdump-mir-dir=" . to_string ( ) ;
2475
2476
dir_opt. push_str ( mir_dump_dir. to_str ( ) . unwrap ( ) ) ;
2476
2477
debug ! ( "dir_opt: {:?}" , dir_opt) ;
@@ -2951,8 +2952,7 @@ impl<'test> TestCx<'test> {
2951
2952
assert ! ( self . revision. is_none( ) , "revisions not relevant here" ) ;
2952
2953
2953
2954
let out_dir = self . output_base_dir ( ) ;
2954
- let _ = fs:: remove_dir_all ( & out_dir) ;
2955
- create_dir_all ( & out_dir) . unwrap ( ) ;
2955
+ remove_and_create_dir_all ( & out_dir) ;
2956
2956
2957
2957
let proc_res = self . document ( & out_dir) ;
2958
2958
if !proc_res. status . success ( ) {
@@ -2986,9 +2986,7 @@ impl<'test> TestCx<'test> {
2986
2986
let suffix =
2987
2987
self . safe_revision ( ) . map_or ( "nightly" . into ( ) , |path| path. to_owned ( ) + "-nightly" ) ;
2988
2988
let compare_dir = output_base_dir ( self . config , self . testpaths , Some ( & suffix) ) ;
2989
- // Don't give an error if the directory didn't already exist
2990
- let _ = fs:: remove_dir_all ( & compare_dir) ;
2991
- create_dir_all ( & compare_dir) . unwrap ( ) ;
2989
+ remove_and_create_dir_all ( & compare_dir) ;
2992
2990
2993
2991
// We need to create a new struct for the lifetimes on `config` to work.
2994
2992
let new_rustdoc = TestCx {
@@ -3137,8 +3135,7 @@ impl<'test> TestCx<'test> {
3137
3135
assert ! ( self . revision. is_none( ) , "revisions not relevant here" ) ;
3138
3136
3139
3137
let out_dir = self . output_base_dir ( ) ;
3140
- let _ = fs:: remove_dir_all ( & out_dir) ;
3141
- create_dir_all ( & out_dir) . unwrap ( ) ;
3138
+ remove_and_create_dir_all ( & out_dir) ;
3142
3139
3143
3140
let proc_res = self . document ( & out_dir) ;
3144
3141
if !proc_res. status . success ( ) {
0 commit comments