Fix display of -NaN%
in borrock stats caused by div by zero
This commit is contained in:
parent
826b835813
commit
4ca127789d
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user