@@ -87,7 +87,6 @@ pub struct Definitions {
8787 parent_modules_of_macro_defs : FxHashMap < ExpnId , DefId > ,
8888 /// Item with a given `LocalDefId` was defined during macro expansion with ID `ExpnId`.
8989 expansions_that_defined : FxHashMap < LocalDefId , ExpnId > ,
90- next_disambiguator : FxHashMap < ( LocalDefId , DefPathData ) , u32 > ,
9190}
9291
9392/// A unique identifier that we can use to lookup a definition
@@ -350,7 +349,6 @@ impl Definitions {
350349 def_id_to_hir_id : Default :: default ( ) ,
351350 hir_id_to_def_id : Default :: default ( ) ,
352351 expansions_that_defined : Default :: default ( ) ,
353- next_disambiguator : Default :: default ( ) ,
354352 parent_modules_of_macro_defs : Default :: default ( ) ,
355353 }
356354 }
@@ -366,20 +364,14 @@ impl Definitions {
366364 parent : LocalDefId ,
367365 data : DefPathData ,
368366 expn_id : ExpnId ,
367+ mut next_disambiguator : impl FnMut ( LocalDefId , DefPathData ) -> u32 ,
369368 ) -> LocalDefId {
370369 debug ! ( "create_def(parent={:?}, data={:?}, expn_id={:?})" , parent, data, expn_id) ;
371370
372371 // The root node must be created with `create_root_def()`.
373372 assert ! ( data != DefPathData :: CrateRoot ) ;
374373
375- // Find the next free disambiguator for this key.
376- let disambiguator = {
377- let next_disamb = self . next_disambiguator . entry ( ( parent, data) ) . or_insert ( 0 ) ;
378- let disambiguator = * next_disamb;
379- * next_disamb = next_disamb. checked_add ( 1 ) . expect ( "disambiguator overflow" ) ;
380- disambiguator
381- } ;
382-
374+ let disambiguator = next_disambiguator ( parent, data) ;
383375 let key = DefKey {
384376 parent : Some ( parent. local_def_index ) ,
385377 disambiguated_data : DisambiguatedDefPathData { data, disambiguator } ,
0 commit comments