diff options
| author | bors <bors@rust-lang.org> | 2018-10-20 11:22:48 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2018-10-20 11:22:48 +0000 |
| commit | ca2639e82ec4a18d7359efbfb555ea69dd644c97 (patch) | |
| tree | 3dfa59589214b0157714150a785dd9cc4ccdc240 /src/librustc_codegen_utils | |
| parent | 94273f4d8e463cac45486328294bb1c2bbc10170 (diff) | |
| parent | d28aed6dc45ffccc790469cb04f3f775ddb2283a (diff) | |
| download | rust-ca2639e82ec4a18d7359efbfb555ea69dd644c97.tar.gz rust-ca2639e82ec4a18d7359efbfb555ea69dd644c97.zip | |
Auto merge of #55014 - ljedrz:lazyboye_unwraps, r=matthewjasper
Prefer unwrap_or_else to unwrap_or in case of function calls/allocations The contents of `unwrap_or` are evaluated eagerly, so it's not a good pick in case of function calls and allocations. This PR also changes a few `unwrap_or`s with `unwrap_or_default`. An added bonus is that in some cases this change also reveals if the object it's called on is an `Option` or a `Result` (based on whether the closure takes an argument).
Diffstat (limited to 'src/librustc_codegen_utils')
| -rw-r--r-- | src/librustc_codegen_utils/link.rs | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/librustc_codegen_utils/link.rs b/src/librustc_codegen_utils/link.rs index 3d47f91a623..2a1fbe6ace5 100644 --- a/src/librustc_codegen_utils/link.rs +++ b/src/librustc_codegen_utils/link.rs @@ -103,7 +103,7 @@ pub fn filename_for_metadata(sess: &Session, let libname = format!("{}{}", crate_name, sess.opts.cg.extra_filename); let out_filename = outputs.single_output_file.clone() - .unwrap_or(outputs.out_directory.join(&format!("lib{}.rmeta", libname))); + .unwrap_or_else(|| outputs.out_directory.join(&format!("lib{}.rmeta", libname))); check_file_is_writeable(&out_filename, sess); |
