replaced some unwrap_or with unwrap_or_else
This commit is contained in:
parent
446d4533e8
commit
5ff1be197e
@ -2082,7 +2082,7 @@ fn add_upstream_rust_crates<'a, B: ArchiveBuilder<'a>>(
|
|||||||
let filestem = cratepath.file_stem().unwrap().to_str().unwrap();
|
let filestem = cratepath.file_stem().unwrap().to_str().unwrap();
|
||||||
cmd.link_rust_dylib(
|
cmd.link_rust_dylib(
|
||||||
Symbol::intern(&unlib(&sess.target, filestem)),
|
Symbol::intern(&unlib(&sess.target, filestem)),
|
||||||
parent.unwrap_or(Path::new("")),
|
parent.unwrap_or_else(|| Path::new("")),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -159,7 +159,7 @@ fn check_panic_str<'tcx>(
|
|||||||
Some(v) if v.len() == 1 => "panic message contains a brace",
|
Some(v) if v.len() == 1 => "panic message contains a brace",
|
||||||
_ => "panic message contains braces",
|
_ => "panic message contains braces",
|
||||||
};
|
};
|
||||||
cx.struct_span_lint(NON_FMT_PANIC, brace_spans.unwrap_or(vec![span]), |lint| {
|
cx.struct_span_lint(NON_FMT_PANIC, brace_spans.unwrap_or_else(|| vec![span]), |lint| {
|
||||||
let mut l = lint.build(msg);
|
let mut l = lint.build(msg);
|
||||||
l.note("this message is not used as a format string, but will be in Rust 2021");
|
l.note("this message is not used as a format string, but will be in Rust 2021");
|
||||||
if span.contains(arg.span) {
|
if span.contains(arg.span) {
|
||||||
|
@ -378,14 +378,14 @@ fn add_query_description_impl(
|
|||||||
let t = &(t.0).0;
|
let t = &(t.0).0;
|
||||||
quote! { #t }
|
quote! { #t }
|
||||||
})
|
})
|
||||||
.unwrap_or(quote! { _ });
|
.unwrap_or_else(|| quote! { _ });
|
||||||
let value = args
|
let value = args
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|t| {
|
.map(|t| {
|
||||||
let t = &(t.1).0;
|
let t = &(t.1).0;
|
||||||
quote! { #t }
|
quote! { #t }
|
||||||
})
|
})
|
||||||
.unwrap_or(quote! { _ });
|
.unwrap_or_else(|| quote! { _ });
|
||||||
// expr is a `Block`, meaning that `{ #expr }` gets expanded
|
// expr is a `Block`, meaning that `{ #expr }` gets expanded
|
||||||
// to `{ { stmts... } }`, which triggers the `unused_braces` lint.
|
// to `{ { stmts... } }`, which triggers the `unused_braces` lint.
|
||||||
quote! {
|
quote! {
|
||||||
|
@ -473,9 +473,9 @@ impl<'a> SessionDiagnosticDeriveBuilder<'a> {
|
|||||||
.map(
|
.map(
|
||||||
|applicability_idx| quote!(#binding.#applicability_idx),
|
|applicability_idx| quote!(#binding.#applicability_idx),
|
||||||
)
|
)
|
||||||
.unwrap_or(quote!(
|
.unwrap_or_else(|| {
|
||||||
rustc_errors::Applicability::Unspecified
|
quote!(rustc_errors::Applicability::Unspecified)
|
||||||
));
|
});
|
||||||
return Ok((span, applicability));
|
return Ok((span, applicability));
|
||||||
}
|
}
|
||||||
throw_span_err!(
|
throw_span_err!(
|
||||||
|
@ -169,7 +169,7 @@ pub fn get_or_default_sysroot() -> PathBuf {
|
|||||||
|
|
||||||
// Check if sysroot is found using env::args().next(), and if is not found,
|
// Check if sysroot is found using env::args().next(), and if is not found,
|
||||||
// use env::current_exe() to imply sysroot.
|
// use env::current_exe() to imply sysroot.
|
||||||
from_env_args_next().unwrap_or(from_current_exe())
|
from_env_args_next().unwrap_or_else(|| from_current_exe())
|
||||||
}
|
}
|
||||||
|
|
||||||
// The name of the directory rustc expects libraries to be located.
|
// The name of the directory rustc expects libraries to be located.
|
||||||
|
@ -348,9 +348,9 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
|
|||||||
let min_list_wb = min_list
|
let min_list_wb = min_list
|
||||||
.iter()
|
.iter()
|
||||||
.map(|captured_place| {
|
.map(|captured_place| {
|
||||||
let locatable = captured_place.info.path_expr_id.unwrap_or(
|
let locatable = captured_place.info.path_expr_id.unwrap_or_else(|| {
|
||||||
self.tcx().hir().local_def_id_to_hir_id(closure_def_id.expect_local()),
|
self.tcx().hir().local_def_id_to_hir_id(closure_def_id.expect_local())
|
||||||
);
|
});
|
||||||
|
|
||||||
self.resolve(captured_place.clone(), &locatable)
|
self.resolve(captured_place.clone(), &locatable)
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user