@@ -176,6 +176,25 @@ impl<'a> NameResolution<'a> {
176
176
}
177
177
}
178
178
179
+ fn increment_outstanding_references ( & mut self , is_public : bool ) {
180
+ self . outstanding_references += 1 ;
181
+ if is_public {
182
+ self . pub_outstanding_references += 1 ;
183
+ }
184
+ }
185
+
186
+ fn decrement_outstanding_references ( & mut self , is_public : bool ) {
187
+ let decrement_references = |count : & mut _ | {
188
+ assert ! ( * count > 0 ) ;
189
+ * count -= 1 ;
190
+ } ;
191
+
192
+ decrement_references ( & mut self . outstanding_references ) ;
193
+ if is_public {
194
+ decrement_references ( & mut self . pub_outstanding_references ) ;
195
+ }
196
+ }
197
+
179
198
fn report_conflicts < F : FnMut ( & NameBinding , & NameBinding ) > ( & self , mut report : F ) {
180
199
let binding = match self . binding {
181
200
Some ( binding) => binding,
@@ -253,25 +272,13 @@ impl<'a> ::ModuleS<'a> {
253
272
}
254
273
255
274
pub fn increment_outstanding_references_for ( & self , name : Name , ns : Namespace , is_public : bool ) {
256
- let mut resolutions = self . resolutions . borrow_mut ( ) ;
257
- let resolution = resolutions. entry ( ( name, ns) ) . or_insert_with ( Default :: default) ;
258
- resolution. outstanding_references += 1 ;
259
- if is_public {
260
- resolution. pub_outstanding_references += 1 ;
261
- }
275
+ self . resolutions . borrow_mut ( ) . entry ( ( name, ns) ) . or_insert_with ( Default :: default)
276
+ . increment_outstanding_references ( is_public) ;
262
277
}
263
278
264
279
fn decrement_outstanding_references_for ( & self , name : Name , ns : Namespace , is_public : bool ) {
265
- let decrement_references = |count : & mut _ | {
266
- assert ! ( * count > 0 ) ;
267
- * count -= 1 ;
268
- } ;
269
-
270
280
self . update_resolution ( name, ns, |resolution| {
271
- decrement_references ( & mut resolution. outstanding_references ) ;
272
- if is_public {
273
- decrement_references ( & mut resolution. pub_outstanding_references ) ;
274
- }
281
+ resolution. decrement_outstanding_references ( is_public) ;
275
282
} )
276
283
}
277
284
0 commit comments