Skip to content

Commit 50985b0

Browse files
committed
Use to_option_with in several places
1 parent e3a8ea4 commit 50985b0

File tree

4 files changed

+10
-7
lines changed

4 files changed

+10
-7
lines changed

src/librustc_codegen_ssa/back/rpath.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ fn path_relative_from(path: &Path, base: &Path) -> Option<PathBuf> {
119119
use std::path::Component;
120120

121121
if path.is_absolute() != base.is_absolute() {
122-
path.is_absolute().to_option(PathBuf::from(path))
122+
path.is_absolute().to_option_with(|| PathBuf::from(path))
123123
} else {
124124
let mut ita = path.components();
125125
let mut itb = base.components();

src/librustc_codegen_ssa/lib.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,14 @@ impl<M> ModuleCodegen<M> {
6969
emit_bc: bool,
7070
emit_bc_compressed: bool,
7171
outputs: &OutputFilenames) -> CompiledModule {
72-
let object = emit_obj.to_option(outputs.temp_path(OutputType::Object, Some(&self.name)));
73-
let bytecode = emit_bc.to_option(outputs.temp_path(OutputType::Bitcode, Some(&self.name)));
74-
let bytecode_compressed = emit_bc_compressed.to_option(
72+
let object = emit_obj
73+
.to_option_with(|| outputs.temp_path(OutputType::Object, Some(&self.name)));
74+
let bytecode = emit_bc
75+
.to_option_with(|| outputs.temp_path(OutputType::Bitcode, Some(&self.name)));
76+
let bytecode_compressed = emit_bc_compressed.to_option_with(|| {
7577
outputs.temp_path(OutputType::Bitcode, Some(&self.name))
76-
.with_extension(RLIB_BYTECODE_EXTENSION));
78+
.with_extension(RLIB_BYTECODE_EXTENSION)
79+
});
7780

7881
CompiledModule {
7982
name: self.name.clone(),

src/librustc_interface/passes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ fn output_contains_path(output_paths: &[PathBuf], input_path: &PathBuf) -> bool
547547
}
548548

549549
fn output_conflicts_with_dir(output_paths: &[PathBuf]) -> Option<PathBuf> {
550-
let check = |output_path: &PathBuf| output_path.is_dir().to_option(output_path.clone());
550+
let check = |output_path: &PathBuf| output_path.is_dir().to_option_with(|| output_path.clone());
551551
check_output(output_paths, check)
552552
}
553553

src/librustc_session/session.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,7 @@ impl Session {
752752
}
753753

754754
pub fn incr_comp_session_dir_opt(&self) -> Option<cell::Ref<'_, PathBuf>> {
755-
self.opts.incremental.is_some().to_option(self.incr_comp_session_dir())
755+
self.opts.incremental.is_some().to_option_with(|| self.incr_comp_session_dir())
756756
}
757757

758758
pub fn print_perf_stats(&self) {

0 commit comments

Comments
 (0)