Avoid unnecessary formatting when trace log level is disabled

This commit is contained in:
Tomasz Miąsko 2021-09-14 00:00:00 +00:00
parent 9f85cd6f2a
commit e84996bd7f

View file

@ -51,10 +51,11 @@ fn eval_body_using_ecx<'mir, 'tcx>(
assert!(!layout.is_unsized()); assert!(!layout.is_unsized());
let ret = ecx.allocate(layout, MemoryKind::Stack)?; let ret = ecx.allocate(layout, MemoryKind::Stack)?;
let name = trace!(
with_no_trimmed_paths(|| ty::tls::with(|tcx| tcx.def_path_str(cid.instance.def_id()))); "eval_body_using_ecx: pushing stack frame for global: {}{}",
let prom = cid.promoted.map_or_else(String::new, |p| format!("::promoted[{:?}]", p)); with_no_trimmed_paths(|| ty::tls::with(|tcx| tcx.def_path_str(cid.instance.def_id()))),
trace!("eval_body_using_ecx: pushing stack frame for global: {}{}", name, prom); cid.promoted.map_or_else(String::new, |p| format!("::promoted[{:?}]", p))
);
ecx.push_stack_frame( ecx.push_stack_frame(
cid.instance, cid.instance,