@@ -19,7 +19,7 @@ use middle::dataflow::DataFlowContext;
19
19
use middle:: dataflow:: DataFlowOperator ;
20
20
use util:: ppaux:: { note_and_explain_region, Repr , UserString } ;
21
21
22
- use std:: cell:: RefCell ;
22
+ use std:: cell:: { Cell , RefCell } ;
23
23
use std:: hashmap:: { HashSet , HashMap } ;
24
24
use std:: ops:: { BitOr , BitAnd } ;
25
25
use std:: result:: { Result } ;
@@ -84,11 +84,10 @@ pub fn check_crate(
84
84
root_map : root_map ( ) ,
85
85
write_guard_map : @RefCell :: new ( HashSet :: new ( ) ) ,
86
86
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 ) ,
92
91
}
93
92
} ;
94
93
let bccx = & mut bccx;
@@ -98,22 +97,20 @@ pub fn check_crate(
98
97
if tcx. sess . borrowck_stats ( ) {
99
98
println ( "--- borrowck stats ---" ) ;
100
99
println ! ( "paths requiring guarantees: {}" ,
101
- bccx. stats. guaranteed_paths) ;
100
+ bccx. stats. guaranteed_paths. get ( ) ) ;
102
101
println ! ( "paths requiring loans : {}" ,
103
- make_stat( bccx, bccx. stats. loaned_paths_same) ) ;
102
+ make_stat( bccx, bccx. stats. loaned_paths_same. get ( ) ) ) ;
104
103
println ! ( "paths requiring imm loans : {}" ,
105
- make_stat( bccx, bccx. stats. loaned_paths_imm) ) ;
104
+ make_stat( bccx, bccx. stats. loaned_paths_imm. get ( ) ) ) ;
106
105
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( ) ) ) ;
110
107
}
111
108
112
109
return ( bccx. root_map , bccx. write_guard_map ) ;
113
110
114
111
fn make_stat ( bccx : & mut BorrowckCtxt , stat : uint ) -> ~str {
115
112
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 ;
117
114
format ! ( "{} ({:.0f}%)" , stat , stat_f * 100.0 / total)
118
115
}
119
116
}
@@ -179,11 +176,10 @@ pub struct BorrowckCtxt {
179
176
}
180
177
181
178
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 > ,
187
183
}
188
184
189
185
// The keys to the root map combine the `id` of the deref expression
0 commit comments