Skip to content

Commit

Permalink
review changes - only show closure ids in verbose mode
Browse files Browse the repository at this point in the history
  • Loading branch information
nrc committed Jun 7, 2015
1 parent 79b0c89 commit 83c73e3
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/librustc/util/ppaux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,11 @@ pub fn ty_to_string<'tcx>(cx: &ctxt<'tcx>, typ: &ty::TyS<'tcx>) -> String {
let mut s = String::new();
s.push_str("[closure");
push_sig_to_string(cx, &mut s, '(', ')', &cty.sig);
s.push_str(&format!(" id={:?}]", did));
if cx.sess.verbose() {
s.push_str(&format!(" id={:?}]", did));
} else {
s.push(']');
}
s
}

Expand Down Expand Up @@ -412,11 +416,18 @@ pub fn ty_to_string<'tcx>(cx: &ctxt<'tcx>, typ: &ty::TyS<'tcx>) -> String {
closure_tys.get(did).map(|closure_type| {
closure_to_string(cx, &closure_type.subst(cx, substs), did)
}).unwrap_or_else(|| {
let id_str = if cx.sess.verbose() {
format!(" id={:?}", did)
} else {
"".to_owned()
};


if did.krate == ast::LOCAL_CRATE {
let span = cx.map.span(did.node);
format!("[closure {} id={:?}]", span.repr(cx), did)
format!("[closure {}{}]", span.repr(cx), id_str)
} else {
format!("[closure id={:?}]", did)
format!("[closure{}]", id_str)
}
})
}
Expand Down

0 comments on commit 83c73e3

Please sign in to comment.