mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-21 17:52:12 +03:00
Prefer unwrap_or_else to unwrap_or in case of function calls/allocations
This commit is contained in:
+2
-2
@@ -97,8 +97,8 @@ fn build_libbacktrace(target: &str) -> Result<(), ()> {
|
||||
.file("../libbacktrace/sort.c")
|
||||
.file("../libbacktrace/state.c");
|
||||
|
||||
let any_debug = env::var("RUSTC_DEBUGINFO").unwrap_or(String::new()) == "true" ||
|
||||
env::var("RUSTC_DEBUGINFO_LINES").unwrap_or(String::new()) == "true";
|
||||
let any_debug = env::var("RUSTC_DEBUGINFO").unwrap_or_default() == "true" ||
|
||||
env::var("RUSTC_DEBUGINFO_LINES").unwrap_or_default() == "true";
|
||||
build.debug(any_debug);
|
||||
|
||||
if target.contains("darwin") {
|
||||
|
||||
@@ -85,7 +85,7 @@ pub unsafe fn cleanup() {
|
||||
}
|
||||
|
||||
pub fn args() -> Args {
|
||||
let bytes = clone().unwrap_or(Vec::new());
|
||||
let bytes = clone().unwrap_or_default();
|
||||
let v: Vec<OsString> = bytes.into_iter().map(|v| {
|
||||
OsStringExt::from_vec(v)
|
||||
}).collect();
|
||||
|
||||
@@ -331,7 +331,7 @@ fn drop(&mut self) {
|
||||
cvt(libc::posix_spawnattr_setflags(&mut attrs.0, flags as _))?;
|
||||
|
||||
let envp = envp.map(|c| c.as_ptr())
|
||||
.unwrap_or(*sys::os::environ() as *const _);
|
||||
.unwrap_or_else(|| *sys::os::environ() as *const _);
|
||||
let ret = libc::posix_spawnp(
|
||||
&mut p.pid,
|
||||
self.get_argv()[0],
|
||||
|
||||
Reference in New Issue
Block a user