Skip to content

Commit 7d33aa8

Browse files
committed
Use to_option_with in several places
1 parent 788b0cf commit 7d33aa8

File tree

4 files changed

+10
-7
lines changed

4 files changed

+10
-7
lines changed

src/librustc/session/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -825,7 +825,7 @@ impl Session {
825825
}
826826

827827
pub fn incr_comp_session_dir_opt(&self) -> Option<cell::Ref<'_, PathBuf>> {
828-
self.opts.incremental.is_some().to_option(self.incr_comp_session_dir())
828+
self.opts.incremental.is_some().to_option_with(|| self.incr_comp_session_dir())
829829
}
830830

831831
pub fn print_perf_stats(&self) {

src/librustc_codegen_ssa/back/rpath.rs

+1-1
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

+7-4
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

+1-1
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,7 @@ fn output_contains_path(output_paths: &[PathBuf], input_path: &PathBuf) -> bool
628628
}
629629

630630
fn output_conflicts_with_dir(output_paths: &[PathBuf]) -> Option<PathBuf> {
631-
let check = |output_path: &PathBuf| output_path.is_dir().to_option(output_path.clone());
631+
let check = |output_path: &PathBuf| output_path.is_dir().to_option_with(|| output_path.clone());
632632
check_output(output_paths, check)
633633
}
634634

0 commit comments

Comments
 (0)