Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 4ca1277

Browse files
committedJul 24, 2014
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

Lines changed: 2 additions & 2 deletions
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

13 commit comments

Comments
 (13)

bors commented on Jul 25, 2014

@bors
Collaborator

saw approval from alexcrichton
at hirschenberger@4ca1277

bors commented on Jul 25, 2014

@bors
Collaborator

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

bors commented on Jul 25, 2014

@bors
Collaborator

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

bors commented on Jul 25, 2014

@bors
Collaborator

saw approval from alexcrichton
at hirschenberger@4ca1277

bors commented on Jul 25, 2014

@bors
Collaborator

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

bors commented on Jul 25, 2014

@bors
Collaborator

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

bors commented on Jul 25, 2014

@bors
Collaborator

saw approval from alexcrichton
at hirschenberger@4ca1277

bors commented on Jul 25, 2014

@bors
Collaborator

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

bors commented on Jul 25, 2014

@bors
Collaborator

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

bors commented on Jul 25, 2014

@bors
Collaborator

fast-forwarding master to auto = d30776e

Please sign in to comment.