about summary refs log tree commit diff
diff options
context:
space:
mode:
authorljedrz <ljedrz@gmail.com>2018-10-12 14:35:07 +0200
committerljedrz <ljedrz@gmail.com>2018-10-13 10:15:46 +0200
commitd838a7fcca93034dcb50914ca242a6973a7c3ac2 (patch)
treeaff1f56252cc375cf677bf52d6d498c163dcc189
parentc46c4d7135a32cb8c5609ac1042858a4151fbd43 (diff)
downloadrust-d838a7fcca93034dcb50914ca242a6973a7c3ac2.tar.gz
rust-d838a7fcca93034dcb50914ca242a6973a7c3ac2.zip
rustc/driver: unwrap_or_else with function calls
-rw-r--r--src/librustc_driver/driver.rs12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs
index 040f835bf5e..976a50e9d69 100644
--- a/src/librustc_driver/driver.rs
+++ b/src/librustc_driver/driver.rs
@@ -44,7 +44,7 @@ use serialize::json;
 
 use std::any::Any;
 use std::env;
-use std::ffi::{OsStr, OsString};
+use std::ffi::OsString;
 use std::fs;
 use std::io::{self, Write};
 use std::iter;
@@ -1648,14 +1648,14 @@ pub fn build_output_filenames(
             // "-" as input file will cause the parser to read from stdin so we
             // have to make up a name
             // We want to toss everything after the final '.'
-            let dirpath = (*odir).as_ref().cloned().unwrap_or_else(|| PathBuf::new());
+            let dirpath = (*odir).as_ref().cloned().unwrap_or_default();
 
             // If a crate name is present, we use it as the link name
             let stem = sess.opts
                 .crate_name
                 .clone()
                 .or_else(|| attr::find_crate_name(attrs).map(|n| n.to_string()))
-                .unwrap_or(input.filestem());
+                .unwrap_or_else(|| input.filestem());
 
             OutputFilenames {
                 out_directory: dirpath,
@@ -1688,13 +1688,11 @@ pub fn build_output_filenames(
                 sess.warn("ignoring -C extra-filename flag due to -o flag");
             }
 
-            let cur_dir = Path::new("");
-
             OutputFilenames {
-                out_directory: out_file.parent().unwrap_or(cur_dir).to_path_buf(),
+                out_directory: out_file.parent().unwrap_or_else(|| Path::new("")).to_path_buf(),
                 out_filestem: out_file
                     .file_stem()
-                    .unwrap_or(OsStr::new(""))
+                    .unwrap_or_default()
                     .to_str()
                     .unwrap()
                     .to_string(),