Skip to content

Commit

Permalink
Fix display of -NaN% in borrock stats caused by div by zero
Browse files Browse the repository at this point in the history
  • Loading branch information
hirschenberger committed Jul 24, 2014
1 parent 826b835 commit 4ca1277
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/librustc/middle/borrowck/mod.rs
Expand Up @@ -98,9 +98,9 @@ pub fn check_crate(tcx: &ty::ctxt,
}

fn make_stat(bccx: &BorrowckCtxt, stat: uint) -> String {
let stat_f = stat as f64;
let total = bccx.stats.guaranteed_paths.get() as f64;
format!("{} ({:.0f}%)", stat , stat_f * 100.0 / total)
let perc = if total == 0.0 { 0.0 } else { stat as f64 * 100.0 / total };
format!("{} ({:.0f}%)", stat, perc)
}
}

Expand Down

13 comments on commit 4ca1277

@bors
Copy link
Contributor

@bors bors commented on 4ca1277 Jul 25, 2014

Choose a reason for hiding this comment

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

saw approval from alexcrichton
at hirschenberger@4ca1277

@bors
Copy link
Contributor

@bors bors commented on 4ca1277 Jul 25, 2014

Choose a reason for hiding this comment

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

merging hirschenberger/rust/borrock-stats-div-by-zero = 4ca1277 into auto

@bors
Copy link
Contributor

@bors bors commented on 4ca1277 Jul 25, 2014

Choose a reason for hiding this comment

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

hirschenberger/rust/borrock-stats-div-by-zero = 4ca1277 merged ok, testing candidate = 64e722ce

@bors
Copy link
Contributor

@bors bors commented on 4ca1277 Jul 25, 2014

Choose a reason for hiding this comment

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

saw approval from alexcrichton
at hirschenberger@4ca1277

@bors
Copy link
Contributor

@bors bors commented on 4ca1277 Jul 25, 2014

Choose a reason for hiding this comment

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

merging hirschenberger/rust/borrock-stats-div-by-zero = 4ca1277 into auto

@bors
Copy link
Contributor

@bors bors commented on 4ca1277 Jul 25, 2014

Choose a reason for hiding this comment

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

hirschenberger/rust/borrock-stats-div-by-zero = 4ca1277 merged ok, testing candidate = f46df3fe

@bors
Copy link
Contributor

@bors bors commented on 4ca1277 Jul 25, 2014

Choose a reason for hiding this comment

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

saw approval from alexcrichton
at hirschenberger@4ca1277

@bors
Copy link
Contributor

@bors bors commented on 4ca1277 Jul 25, 2014

Choose a reason for hiding this comment

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

merging hirschenberger/rust/borrock-stats-div-by-zero = 4ca1277 into auto

@bors
Copy link
Contributor

@bors bors commented on 4ca1277 Jul 25, 2014

Choose a reason for hiding this comment

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

hirschenberger/rust/borrock-stats-div-by-zero = 4ca1277 merged ok, testing candidate = d30776e

@bors
Copy link
Contributor

@bors bors commented on 4ca1277 Jul 25, 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 = d30776e

Please sign in to comment.