@@ -12,7 +12,6 @@ pub mod rustc;
12
12
pub mod rustdoc;
13
13
14
14
use std:: env;
15
- use std:: fs;
16
15
use std:: io;
17
16
use std:: path:: { Path , PathBuf } ;
18
17
use std:: process:: { Command , Output } ;
@@ -35,10 +34,6 @@ pub fn tmp_dir() -> PathBuf {
35
34
env:: var_os ( "TMPDIR" ) . unwrap ( ) . into ( )
36
35
}
37
36
38
- pub fn tmp_path < P : AsRef < Path > > ( path : P ) -> PathBuf {
39
- tmp_dir ( ) . join ( path. as_ref ( ) )
40
- }
41
-
42
37
/// `TARGET`
43
38
pub fn target ( ) -> String {
44
39
env:: var ( "TARGET" ) . unwrap ( )
@@ -62,7 +57,7 @@ pub fn is_darwin() -> bool {
62
57
/// Construct a path to a static library under `$TMPDIR` given the library name. This will return a
63
58
/// path with `$TMPDIR` joined with platform-and-compiler-specific library name.
64
59
pub fn static_lib ( name : & str ) -> PathBuf {
65
- tmp_path ( static_lib_name ( name) )
60
+ tmp_dir ( ) . join ( static_lib_name ( name) )
66
61
}
67
62
68
63
pub fn python_command ( ) -> Command {
@@ -107,7 +102,7 @@ pub fn static_lib_name(name: &str) -> String {
107
102
/// Construct a path to a dynamic library under `$TMPDIR` given the library name. This will return a
108
103
/// path with `$TMPDIR` joined with platform-and-compiler-specific library name.
109
104
pub fn dynamic_lib ( name : & str ) -> PathBuf {
110
- tmp_path ( dynamic_lib_name ( name) )
105
+ tmp_dir ( ) . join ( dynamic_lib_name ( name) )
111
106
}
112
107
113
108
/// Construct the dynamic library name based on the platform.
@@ -218,15 +213,15 @@ pub fn copy_dir_all(src: impl AsRef<Path>, dst: impl AsRef<Path>) {
218
213
fn copy_dir_all_inner ( src : impl AsRef < Path > , dst : impl AsRef < Path > ) -> io:: Result < ( ) > {
219
214
let dst = dst. as_ref ( ) ;
220
215
if !dst. is_dir ( ) {
221
- fs:: create_dir_all ( & dst) ?;
216
+ std :: fs:: create_dir_all ( & dst) ?;
222
217
}
223
- for entry in fs:: read_dir ( src) ? {
218
+ for entry in std :: fs:: read_dir ( src) ? {
224
219
let entry = entry?;
225
220
let ty = entry. file_type ( ) ?;
226
221
if ty. is_dir ( ) {
227
222
copy_dir_all_inner ( entry. path ( ) , dst. join ( entry. file_name ( ) ) ) ?;
228
223
} else {
229
- fs:: copy ( entry. path ( ) , dst. join ( entry. file_name ( ) ) ) ?;
224
+ std :: fs:: copy ( entry. path ( ) , dst. join ( entry. file_name ( ) ) ) ?;
230
225
}
231
226
}
232
227
Ok ( ( ) )
@@ -245,15 +240,8 @@ pub fn copy_dir_all(src: impl AsRef<Path>, dst: impl AsRef<Path>) {
245
240
246
241
/// Check that all files in `dir1` exist and have the same content in `dir2`. Panic otherwise.
247
242
pub fn recursive_diff ( dir1 : impl AsRef < Path > , dir2 : impl AsRef < Path > ) {
248
- fn read_file ( path : & Path ) -> Vec < u8 > {
249
- match fs:: read ( path) {
250
- Ok ( c) => c,
251
- Err ( e) => panic ! ( "Failed to read `{}`: {:?}" , path. display( ) , e) ,
252
- }
253
- }
254
-
255
243
let dir2 = dir2. as_ref ( ) ;
256
- for entry in fs:: read_dir ( dir1) . unwrap ( ) {
244
+ for entry in fs:: read_dir ( dir1) {
257
245
let entry = entry. unwrap ( ) ;
258
246
let entry_name = entry. file_name ( ) ;
259
247
let path = entry. path ( ) ;
@@ -262,8 +250,8 @@ pub fn recursive_diff(dir1: impl AsRef<Path>, dir2: impl AsRef<Path>) {
262
250
recursive_diff ( & path, & dir2. join ( entry_name) ) ;
263
251
} else {
264
252
let path2 = dir2. join ( entry_name) ;
265
- let file1 = read_file ( & path) ;
266
- let file2 = read_file ( & path2) ;
253
+ let file1 = fs :: read ( & path) ;
254
+ let file2 = fs :: read ( & path2) ;
267
255
268
256
// We don't use `assert_eq!` because they are `Vec<u8>`, so not great for display.
269
257
// Why not using String? Because there might be minified files or even potentially
0 commit comments