about summary refs log tree commit diff
path: root/src/librustc_codegen_ssa
diff options
context:
space:
mode:
authorvarkor <github@varkor.com>2019-10-08 23:09:36 +0100
committervarkor <github@varkor.com>2019-12-06 12:23:23 +0000
commit50985b012a6d14a1bee8ddf8d086d1741858dd3f (patch)
tree05552096e531ee5e338a6de1d2acfec982dcea74 /src/librustc_codegen_ssa
parente3a8ea4e18a50da60036d2731768a9cb78c90f5a (diff)
downloadrust-50985b012a6d14a1bee8ddf8d086d1741858dd3f.tar.gz
rust-50985b012a6d14a1bee8ddf8d086d1741858dd3f.zip
Use `to_option_with` in several places
Diffstat (limited to 'src/librustc_codegen_ssa')
-rw-r--r--src/librustc_codegen_ssa/back/rpath.rs2
-rw-r--r--src/librustc_codegen_ssa/lib.rs11
2 files changed, 8 insertions, 5 deletions
diff --git a/src/librustc_codegen_ssa/back/rpath.rs b/src/librustc_codegen_ssa/back/rpath.rs
index b932a202093..c61f16da264 100644
--- a/src/librustc_codegen_ssa/back/rpath.rs
+++ b/src/librustc_codegen_ssa/back/rpath.rs
@@ -119,7 +119,7 @@ fn path_relative_from(path: &Path, base: &Path) -> Option<PathBuf> {
     use std::path::Component;
 
     if path.is_absolute() != base.is_absolute() {
-        path.is_absolute().to_option(PathBuf::from(path))
+        path.is_absolute().to_option_with(|| PathBuf::from(path))
     } else {
         let mut ita = path.components();
         let mut itb = base.components();
diff --git a/src/librustc_codegen_ssa/lib.rs b/src/librustc_codegen_ssa/lib.rs
index ebddff2af6e..2c2150e01a3 100644
--- a/src/librustc_codegen_ssa/lib.rs
+++ b/src/librustc_codegen_ssa/lib.rs
@@ -69,11 +69,14 @@ impl<M> ModuleCodegen<M> {
                             emit_bc: bool,
                             emit_bc_compressed: bool,
                             outputs: &OutputFilenames) -> CompiledModule {
-        let object = emit_obj.to_option(outputs.temp_path(OutputType::Object, Some(&self.name)));
-        let bytecode = emit_bc.to_option(outputs.temp_path(OutputType::Bitcode, Some(&self.name)));
-        let bytecode_compressed = emit_bc_compressed.to_option(
+        let object = emit_obj
+            .to_option_with(|| outputs.temp_path(OutputType::Object, Some(&self.name)));
+        let bytecode = emit_bc
+            .to_option_with(|| outputs.temp_path(OutputType::Bitcode, Some(&self.name)));
+        let bytecode_compressed = emit_bc_compressed.to_option_with(|| {
             outputs.temp_path(OutputType::Bitcode, Some(&self.name))
-                    .with_extension(RLIB_BYTECODE_EXTENSION));
+                .with_extension(RLIB_BYTECODE_EXTENSION)
+        });
 
         CompiledModule {
             name: self.name.clone(),