1
Fork 0

Rollup merge of #83526 - klensy:lazy-too, r=petrochenkov

lazily calls some fns

Replaced some fn's with it's lazy variants.
This commit is contained in:
Yuki Okushi 2021-03-28 01:33:16 +09:00 committed by GitHub
commit fa70398d6d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 14 additions and 13 deletions

View file

@ -2327,7 +2327,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
ExprKind::Call(ref callee, ref arguments) => {
self.resolve_expr(callee, Some(expr));
let const_args = self.r.legacy_const_generic_args(callee).unwrap_or(Vec::new());
let const_args = self.r.legacy_const_generic_args(callee).unwrap_or_default();
for (idx, argument) in arguments.iter().enumerate() {
// Constant arguments need to be treated as AnonConst since
// that is how they will be later lowered to HIR.

View file

@ -184,7 +184,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
PathResult::Module(ModuleOrUniformRoot::Module(module)) => module.res(),
_ => None,
}
.map_or(String::new(), |res| format!("{} ", res.descr()));
.map_or_else(String::new, |res| format!("{} ", res.descr()));
(mod_prefix, format!("`{}`", Segment::names_to_string(mod_path)))
};
(
@ -1042,10 +1042,10 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
if let Some(span) = self.def_span(def_id) {
err.span_label(span, &format!("`{}` defined here", path_str));
}
let fields =
self.r.field_names.get(&def_id).map_or("/* fields */".to_string(), |fields| {
vec!["_"; fields.len()].join(", ")
});
let fields = self.r.field_names.get(&def_id).map_or_else(
|| "/* fields */".to_string(),
|fields| vec!["_"; fields.len()].join(", "),
);
err.span_suggestion(
span,
"use the tuple variant pattern syntax instead",