Skip to content

Commit 4ca1277

Browse files
Fix display of -NaN% in borrock stats caused by div by zero
1 parent 826b835 commit 4ca1277

File tree

1 file changed

+2
-2
lines changed
  • src/librustc/middle/borrowck

1 file changed

+2
-2
lines changed

src/librustc/middle/borrowck/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,9 @@ pub fn check_crate(tcx: &ty::ctxt,
9898
}
9999

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

0 commit comments

Comments
 (0)