Skip to content

Commit 83c73e3

Browse files
committed
review changes - only show closure ids in verbose mode
1 parent 79b0c89 commit 83c73e3

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/librustc/util/ppaux.rs

+14-3
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,11 @@ pub fn ty_to_string<'tcx>(cx: &ctxt<'tcx>, typ: &ty::TyS<'tcx>) -> String {
311311
let mut s = String::new();
312312
s.push_str("[closure");
313313
push_sig_to_string(cx, &mut s, '(', ')', &cty.sig);
314-
s.push_str(&format!(" id={:?}]", did));
314+
if cx.sess.verbose() {
315+
s.push_str(&format!(" id={:?}]", did));
316+
} else {
317+
s.push(']');
318+
}
315319
s
316320
}
317321

@@ -412,11 +416,18 @@ pub fn ty_to_string<'tcx>(cx: &ctxt<'tcx>, typ: &ty::TyS<'tcx>) -> String {
412416
closure_tys.get(did).map(|closure_type| {
413417
closure_to_string(cx, &closure_type.subst(cx, substs), did)
414418
}).unwrap_or_else(|| {
419+
let id_str = if cx.sess.verbose() {
420+
format!(" id={:?}", did)
421+
} else {
422+
"".to_owned()
423+
};
424+
425+
415426
if did.krate == ast::LOCAL_CRATE {
416427
let span = cx.map.span(did.node);
417-
format!("[closure {} id={:?}]", span.repr(cx), did)
428+
format!("[closure {}{}]", span.repr(cx), id_str)
418429
} else {
419-
format!("[closure id={:?}]", did)
430+
format!("[closure{}]", id_str)
420431
}
421432
})
422433
}

0 commit comments

Comments
 (0)