Skip to content

Commit

Permalink
auto merge of #15958 : hirschenberger/rust/borrock-stats-div-by-zero,…
Browse files Browse the repository at this point in the history
… r=alexcrichton

`rustc -Z borrowck-stats` displays ugly `-NaN%` in the stats

```
paths requiring guarantees: 0
paths requiring loans     : 0 (-NaN%)
paths requiring imm loans : 0 (-NaN%)
stable paths              : 0 (-NaN%)
```
  • Loading branch information
bors committed Jul 25, 2014
2 parents 7ff5bbd + 4ca1277 commit d30776e
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

0 comments on commit d30776e

Please sign in to comment.