Skip to content

Commit d30776e

Browse files
committed
auto merge of #15958 : hirschenberger/rust/borrock-stats-div-by-zero, 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%) ```
2 parents 7ff5bbd + 4ca1277 commit d30776e

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)