@@ -58,6 +58,7 @@ use syntax::visit;
5858use syntax:: visit:: Visitor ;
5959
6060use std:: collections:: { HashMap , HashSet } ;
61+ use std:: collections:: hashmap:: { Occupied , Vacant } ;
6162use std:: cell:: { Cell , RefCell } ;
6263use std:: gc:: GC ;
6364use std:: mem:: replace;
@@ -2813,10 +2814,13 @@ impl<'a> Resolver<'a> {
28132814 let is_public = import_directive. is_public ;
28142815
28152816 let mut import_resolutions = module_. import_resolutions . borrow_mut ( ) ;
2816- let dest_import_resolution = import_resolutions. find_or_insert_with ( name, |_| {
2817- // Create a new import resolution from this child.
2818- ImportResolution :: new ( id, is_public)
2819- } ) ;
2817+ let dest_import_resolution = match import_resolutions. entry ( name) {
2818+ Occupied ( entry) => entry. into_mut ( ) ,
2819+ Vacant ( entry) => {
2820+ // Create a new import resolution from this child.
2821+ entry. set ( ImportResolution :: new ( id, is_public) )
2822+ }
2823+ } ;
28202824
28212825 debug ! ( "(resolving glob import) writing resolution `{}` in `{}` \
28222826 to `{}`",
@@ -5991,19 +5995,21 @@ impl<'a> Resolver<'a> {
59915995 assert ! ( match lp { LastImport { ..} => false , _ => true } ,
59925996 "Import should only be used for `use` directives" ) ;
59935997 self . last_private . insert ( node_id, lp) ;
5994- self . def_map . borrow_mut ( ) . insert_or_update_with ( node_id, def, |_, old_value| {
5998+
5999+ match self . def_map . borrow_mut ( ) . entry ( node_id) {
59956000 // Resolve appears to "resolve" the same ID multiple
59966001 // times, so here is a sanity check it at least comes to
59976002 // the same conclusion! - nmatsakis
5998- if def != * old_value {
6003+ Occupied ( entry ) => if def != * entry . get ( ) {
59996004 self . session
60006005 . bug ( format ! ( "node_id {:?} resolved first to {:?} and \
60016006 then {:?}",
60026007 node_id,
6003- * old_value ,
6008+ * entry . get ( ) ,
60046009 def) . as_slice ( ) ) ;
6005- }
6006- } ) ;
6010+ } ,
6011+ Vacant ( entry) => { entry. set ( def) ; } ,
6012+ }
60076013 }
60086014
60096015 fn enforce_default_binding_mode ( & mut self ,
0 commit comments