@@ -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,26 +272,8 @@ 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
- }
262
- }
263
-
264
- 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
- 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
- }
275
- } )
275
+ self . resolutions . borrow_mut ( ) . entry ( ( name, ns) ) . or_insert_with ( Default :: default)
276
+ . increment_outstanding_references ( is_public) ;
276
277
}
277
278
278
279
// Use `update` to mutate the resolution for the name.
@@ -477,7 +478,8 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
477
478
// Temporarily count the directive as determined so that the resolution fails
478
479
// (as opposed to being indeterminate) when it can only be defined by the directive.
479
480
if !determined {
480
- module_. decrement_outstanding_references_for ( target, ns, directive. is_public )
481
+ module_. resolutions . borrow_mut ( ) . get_mut ( & ( target, ns) ) . unwrap ( )
482
+ . decrement_outstanding_references ( directive. is_public ) ;
481
483
}
482
484
let result =
483
485
self . resolver . resolve_name_in_module ( target_module, source, ns, false , true ) ;
@@ -514,7 +516,10 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
514
516
self . report_conflict ( target, ns, & directive. import ( binding, None ) , old_binding) ;
515
517
}
516
518
}
517
- module_. decrement_outstanding_references_for ( target, ns, directive. is_public ) ;
519
+
520
+ module_. update_resolution ( target, ns, |resolution| {
521
+ resolution. decrement_outstanding_references ( directive. is_public ) ;
522
+ } )
518
523
}
519
524
520
525
match ( & value_result, & type_result) {
0 commit comments