Skip to content

Commit a5ec857

Browse files
Changed unwrap_or to unwrap_or_else in some places.
The discussion seems to have resolved that this lint is a bit "noisy" in that applying it in all places would result in a reduction in readability. A few of the trivial functions (like `Path::new`) are fine to leave outside of closures. The general rule seems to be that anything that is obviously an allocation (`Box`, `Vec`, `vec![]`) should be in a closure, even if it is a 0-sized allocation.
1 parent 65ae469 commit a5ec857

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/bin/cg_clif.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ impl rustc_driver::Callbacks for CraneliftPassesCallbacks {
2727
config.opts.cg.panic = Some(PanicStrategy::Abort);
2828
config.opts.debugging_opts.panic_abort_tests = true;
2929
config.opts.maybe_sysroot = Some(
30-
config.opts.maybe_sysroot.clone().unwrap_or(
31-
std::env::current_exe()
30+
config.opts.maybe_sysroot.clone().unwrap_or_else(
31+
|| std::env::current_exe()
3232
.unwrap()
3333
.parent()
3434
.unwrap()

0 commit comments

Comments
 (0)