replaced some map_or with map_or_else
This commit is contained in:
parent
5ff1be197e
commit
c75c4a579b
12 changed files with 82 additions and 70 deletions
|
@ -1695,7 +1695,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
|
|||
} else {
|
||||
self.fcx
|
||||
.associated_item(def_id, name, Namespace::ValueNS)
|
||||
.map_or(Vec::new(), |x| vec![x])
|
||||
.map_or_else(|| Vec::new(), |x| vec![x])
|
||||
}
|
||||
} else {
|
||||
self.tcx.associated_items(def_id).in_definition_order().copied().collect()
|
||||
|
|
|
@ -1062,7 +1062,10 @@ fn report_unexpected_variant_res(tcx: TyCtxt<'_>, res: Res, span: Span) {
|
|||
E0533,
|
||||
"expected unit struct, unit variant or constant, found {}{}",
|
||||
res.descr(),
|
||||
tcx.sess.source_map().span_to_snippet(span).map_or(String::new(), |s| format!(" `{}`", s)),
|
||||
tcx.sess
|
||||
.source_map()
|
||||
.span_to_snippet(span)
|
||||
.map_or_else(|_| String::new(), |s| format!(" `{}`", s)),
|
||||
)
|
||||
.emit();
|
||||
}
|
||||
|
|
|
@ -879,7 +879,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
let sm = tcx.sess.source_map();
|
||||
let path_str = sm
|
||||
.span_to_snippet(sm.span_until_char(pat.span, '('))
|
||||
.map_or(String::new(), |s| format!(" `{}`", s.trim_end()));
|
||||
.map_or_else(|_| String::new(), |s| format!(" `{}`", s.trim_end()));
|
||||
let msg = format!(
|
||||
"expected tuple struct or tuple variant, found {}{}",
|
||||
res.descr(),
|
||||
|
|
|
@ -2387,7 +2387,7 @@ fn compute_sig_of_foreign_fn_decl<'tcx>(
|
|||
.sess
|
||||
.source_map()
|
||||
.span_to_snippet(ast_ty.span)
|
||||
.map_or(String::new(), |s| format!(" `{}`", s));
|
||||
.map_or_else(|_| String::new(), |s| format!(" `{}`", s));
|
||||
tcx.sess
|
||||
.struct_span_err(
|
||||
ast_ty.span,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue