Skip to content

Commit

Permalink
Better debug printouts
Browse files Browse the repository at this point in the history
  • Loading branch information
nikomatsakis committed Nov 5, 2014
1 parent dfe8402 commit 81c00e6
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 13 deletions.
8 changes: 4 additions & 4 deletions src/librustc/middle/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1167,25 +1167,25 @@ impl cmp::PartialEq for InferRegion {

impl fmt::Show for TyVid {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result{
write!(f, "<generic #{}>", self.index)
write!(f, "_#{}t", self.index)
}
}

impl fmt::Show for IntVid {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "<generic integer #{}>", self.index)
write!(f, "_#{}i", self.index)
}
}

impl fmt::Show for FloatVid {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "<generic float #{}>", self.index)
write!(f, "_#{}f", self.index)
}
}

impl fmt::Show for RegionVid {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "'<generic lifetime #{}>", self.index)
write!(f, "'_#{}r", self.index)
}
}

Expand Down
12 changes: 12 additions & 0 deletions src/librustc/middle/typeck/infer/region_inference/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -952,6 +952,11 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
-> Vec<VarValue>
{
let mut var_data = self.construct_var_data();

// Dorky hack to cause `dump_constraints` to only get called
// if debug mode is enabled:
debug!("----() End constraint listing {}---", self.dump_constraints());

self.expansion(var_data.as_mut_slice());
self.contraction(var_data.as_mut_slice());
let values =
Expand All @@ -974,6 +979,13 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
})
}

fn dump_constraints(&self) {
debug!("----() Start constraint listing ()----");
for (idx, (constraint, _)) in self.constraints.borrow().iter().enumerate() {
debug!("Constraint {} => {}", idx, constraint.repr(self.tcx));
}
}

fn expansion(&self, var_data: &mut [VarData]) {
self.iterate_until_fixed_point("Expansion", |constraint| {
debug!("expansion: constraint={} origin={}",
Expand Down
14 changes: 5 additions & 9 deletions src/librustc/util/ppaux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,14 +373,10 @@ pub fn ty_to_string(cx: &ctxt, typ: t) -> String {
fn infer_ty_to_string(cx: &ctxt, ty: ty::InferTy) -> String {
let print_var_ids = cx.sess.verbose();
match ty {
ty::TyVar(ty::TyVid { index: vid }) if print_var_ids =>
format!("_#{}", vid),
ty::IntVar(ty::IntVid { index: vid }) if print_var_ids =>
format!("_#{}i", vid),
ty::FloatVar(ty::FloatVid { index: vid }) if print_var_ids =>
format!("_#{}f", vid),
ty::TyVar(_) | ty::IntVar(_) | ty::FloatVar(_) =>
"_".to_string(),
ty::TyVar(ref vid) if print_var_ids => vid.repr(cx),
ty::IntVar(ref vid) if print_var_ids => vid.repr(cx),
ty::FloatVar(ref vid) if print_var_ids => vid.repr(cx),
ty::TyVar(_) | ty::IntVar(_) | ty::FloatVar(_) => format!("_"),
ty::SkolemizedTy(v) => format!("SkolemizedTy({})", v),
ty::SkolemizedIntTy(v) => format!("SkolemizedIntTy({})", v)
}
Expand Down Expand Up @@ -858,7 +854,7 @@ impl Repr for ty::Region {
}

ty::ReInfer(ReVar(ref vid)) => {
format!("ReInfer({})", vid.index)
format!("{}", vid)
}

ty::ReInfer(ReSkolemized(id, ref bound_region)) => {
Expand Down

9 comments on commit 81c00e6

@bors
Copy link
Contributor

@bors bors commented on 81c00e6 Nov 5, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from pcwalton
at nikomatsakis@81c00e6

@bors
Copy link
Contributor

@bors bors commented on 81c00e6 Nov 5, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging nikomatsakis/rust/operator-dispatch = 81c00e6 into auto

@bors
Copy link
Contributor

@bors bors commented on 81c00e6 Nov 5, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nikomatsakis/rust/operator-dispatch = 81c00e6 merged ok, testing candidate = 67179067

@bors
Copy link
Contributor

@bors bors commented on 81c00e6 Nov 5, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from pcwalton
at nikomatsakis@81c00e6

@bors
Copy link
Contributor

@bors bors commented on 81c00e6 Nov 5, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging nikomatsakis/rust/operator-dispatch = 81c00e6 into auto

@bors
Copy link
Contributor

@bors bors commented on 81c00e6 Nov 5, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nikomatsakis/rust/operator-dispatch = 81c00e6 merged ok, testing candidate = 63c4f22

@bors
Copy link
Contributor

@bors bors commented on 81c00e6 Nov 6, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on 81c00e6 Nov 6, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = 63c4f22

Please sign in to comment.