Prefer unwrap_or_else to unwrap_or in case of function calls/allocations

This commit is contained in:
ljedrz
2018-10-12 16:16:00 +02:00
parent cb5e1b93e3
commit d28aed6dc4
35 changed files with 57 additions and 54 deletions

View File

@@ -3228,7 +3228,7 @@ impl<'a> Parser<'a> {
}));
let expr_str = self.sess.source_map().span_to_snippet(expr.span)
.unwrap_or(pprust::expr_to_string(&expr));
.unwrap_or_else(|_| pprust::expr_to_string(&expr));
err.span_suggestion_with_applicability(
expr.span,
&format!("try {} the cast value", op_verb),