Skip to content

Commit 5a9c37b

Browse files
committed
librustc: De-@mut the borrow check stat fields
1 parent df0c13d commit 5a9c37b

File tree

1 file changed

+14
-18
lines changed
  • src/librustc/middle/borrowck

1 file changed

+14
-18
lines changed

src/librustc/middle/borrowck/mod.rs

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use middle::dataflow::DataFlowContext;
1919
use middle::dataflow::DataFlowOperator;
2020
use util::ppaux::{note_and_explain_region, Repr, UserString};
2121

22-
use std::cell::RefCell;
22+
use std::cell::{Cell, RefCell};
2323
use std::hashmap::{HashSet, HashMap};
2424
use std::ops::{BitOr, BitAnd};
2525
use std::result::{Result};
@@ -84,11 +84,10 @@ pub fn check_crate(
8484
root_map: root_map(),
8585
write_guard_map: @RefCell::new(HashSet::new()),
8686
stats: @mut BorrowStats {
87-
loaned_paths_same: 0,
88-
loaned_paths_imm: 0,
89-
stable_paths: 0,
90-
req_pure_paths: 0,
91-
guaranteed_paths: 0,
87+
loaned_paths_same: Cell::new(0),
88+
loaned_paths_imm: Cell::new(0),
89+
stable_paths: Cell::new(0),
90+
guaranteed_paths: Cell::new(0),
9291
}
9392
};
9493
let bccx = &mut bccx;
@@ -98,22 +97,20 @@ pub fn check_crate(
9897
if tcx.sess.borrowck_stats() {
9998
println("--- borrowck stats ---");
10099
println!("paths requiring guarantees: {}",
101-
bccx.stats.guaranteed_paths);
100+
bccx.stats.guaranteed_paths.get());
102101
println!("paths requiring loans : {}",
103-
make_stat(bccx, bccx.stats.loaned_paths_same));
102+
make_stat(bccx, bccx.stats.loaned_paths_same.get()));
104103
println!("paths requiring imm loans : {}",
105-
make_stat(bccx, bccx.stats.loaned_paths_imm));
104+
make_stat(bccx, bccx.stats.loaned_paths_imm.get()));
106105
println!("stable paths : {}",
107-
make_stat(bccx, bccx.stats.stable_paths));
108-
println!("paths requiring purity : {}",
109-
make_stat(bccx, bccx.stats.req_pure_paths));
106+
make_stat(bccx, bccx.stats.stable_paths.get()));
110107
}
111108

112109
return (bccx.root_map, bccx.write_guard_map);
113110

114111
fn make_stat(bccx: &mut BorrowckCtxt, stat: uint) -> ~str {
115112
let stat_f = stat as f64;
116-
let total = bccx.stats.guaranteed_paths as f64;
113+
let total = bccx.stats.guaranteed_paths.get() as f64;
117114
format!("{} ({:.0f}%)", stat , stat_f * 100.0 / total)
118115
}
119116
}
@@ -179,11 +176,10 @@ pub struct BorrowckCtxt {
179176
}
180177

181178
pub struct BorrowStats {
182-
loaned_paths_same: uint,
183-
loaned_paths_imm: uint,
184-
stable_paths: uint,
185-
req_pure_paths: uint,
186-
guaranteed_paths: uint
179+
loaned_paths_same: Cell<uint>,
180+
loaned_paths_imm: Cell<uint>,
181+
stable_paths: Cell<uint>,
182+
guaranteed_paths: Cell<uint>,
187183
}
188184

189185
// The keys to the root map combine the `id` of the deref expression

0 commit comments

Comments
 (0)