]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_back/tempdir.rs
Rollup merge of #31999 - bluss:fundamental-raw-ptr, r=eddyb
[rust.git] / src / librustc_back / tempdir.rs
index 522d66cb563a344d8a404b3776bdba3d75fefa99..04739c7418cd0333e8516723de5f794a6c258df2 100644 (file)
@@ -38,8 +38,12 @@ impl TempDir {
     #[allow(deprecated)] // rand usage
     pub fn new_in<P: AsRef<Path>>(tmpdir: P, prefix: &str)
                                   -> io::Result<TempDir> {
+        Self::_new_in(tmpdir.as_ref(), prefix)
+    }
+
+    fn _new_in(tmpdir: &Path, prefix: &str) -> io::Result<TempDir> {
         let storage;
-        let mut tmpdir = tmpdir.as_ref();
+        let mut tmpdir = tmpdir;
         if !tmpdir.is_absolute() {
             let cur_dir = try!(env::current_dir());
             storage = cur_dir.join(tmpdir);
@@ -50,7 +54,7 @@ pub fn new_in<P: AsRef<Path>>(tmpdir: P, prefix: &str)
         let mut rng = thread_rng();
         for _ in 0..NUM_RETRIES {
             let suffix: String = rng.gen_ascii_chars().take(NUM_RAND_CHARS).collect();
-            let leaf = if prefix.len() > 0 {
+            let leaf = if !prefix.is_empty() {
                 format!("{}.{}", prefix, suffix)
             } else {
                 // If we're given an empty string for a prefix, then creating a
@@ -75,7 +79,6 @@ pub fn new_in<P: AsRef<Path>>(tmpdir: P, prefix: &str)
     /// deleted once the returned wrapper is destroyed.
     ///
     /// If no directory can be created, `Err` is returned.
-    #[allow(deprecated)]
     pub fn new(prefix: &str) -> io::Result<TempDir> {
         TempDir::new_in(&env::temp_dir(), prefix)
     }