@@ -1457,12 +1457,12 @@ mod tests {
14571457 use prelude:: v1:: * ;
14581458 use io:: prelude:: * ;
14591459
1460- use env;
14611460 use fs:: { self , File , OpenOptions } ;
14621461 use io:: { ErrorKind , SeekFrom } ;
1463- use path:: { Path , PathBuf } ;
1464- use rand:: { self , StdRng , Rng } ;
1462+ use path:: Path ;
1463+ use rand:: { StdRng , Rng } ;
14651464 use str;
1465+ use sys_common:: io:: test:: { TempDir , tmpdir} ;
14661466
14671467 #[ cfg( windows) ]
14681468 use os:: windows:: fs:: { symlink_dir, symlink_file} ;
@@ -1490,37 +1490,6 @@ mod tests {
14901490 }
14911491 ) }
14921492
1493- pub struct TempDir ( PathBuf ) ;
1494-
1495- impl TempDir {
1496- fn join ( & self , path : & str ) -> PathBuf {
1497- let TempDir ( ref p) = * self ;
1498- p. join ( path)
1499- }
1500-
1501- fn path < ' a > ( & ' a self ) -> & ' a Path {
1502- let TempDir ( ref p) = * self ;
1503- p
1504- }
1505- }
1506-
1507- impl Drop for TempDir {
1508- fn drop ( & mut self ) {
1509- // Gee, seeing how we're testing the fs module I sure hope that we
1510- // at least implement this correctly!
1511- let TempDir ( ref p) = * self ;
1512- check ! ( fs:: remove_dir_all( p) ) ;
1513- }
1514- }
1515-
1516- pub fn tmpdir ( ) -> TempDir {
1517- let p = env:: temp_dir ( ) ;
1518- let mut r = rand:: thread_rng ( ) ;
1519- let ret = p. join ( & format ! ( "rust-{}" , r. next_u32( ) ) ) ;
1520- check ! ( fs:: create_dir( & ret) ) ;
1521- TempDir ( ret)
1522- }
1523-
15241493 // Several test fail on windows if the user does not have permission to
15251494 // create symlinks (the `SeCreateSymbolicLinkPrivilege`). Instead of
15261495 // disabling these test on Windows, use this function to test whether we
0 commit comments