@@ -1207,29 +1207,22 @@ impl<'a> Resolver<'a> {
12071207 match ns { ValueNS => & mut self . value_ribs , TypeNS => & mut self . type_ribs }
12081208 }
12091209
1210- #[ inline]
1211- fn record_use ( & mut self , name : Name , binding : & ' a NameBinding < ' a > ) {
1210+ fn record_use ( & mut self , name : Name , ns : Namespace , binding : & ' a NameBinding < ' a > ) {
12121211 // track extern crates for unused_extern_crate lint
12131212 if let Some ( DefId { krate, .. } ) = binding. module ( ) . and_then ( ModuleS :: def_id) {
12141213 self . used_crates . insert ( krate) ;
12151214 }
12161215
1217- let directive = match binding. kind {
1218- NameBindingKind :: Import { directive, .. } => directive,
1219- _ => return ,
1220- } ;
1221-
1222- if !self . make_glob_map {
1223- return ;
1224- }
1225- if self . glob_map . contains_key ( & directive. id ) {
1226- self . glob_map . get_mut ( & directive. id ) . unwrap ( ) . insert ( name) ;
1227- return ;
1216+ if let NameBindingKind :: Import { directive, .. } = binding. kind {
1217+ self . used_imports . insert ( ( directive. id , ns) ) ;
1218+ self . add_to_glob_map ( directive. id , name) ;
12281219 }
1220+ }
12291221
1230- let mut new_set = FnvHashSet ( ) ;
1231- new_set. insert ( name) ;
1232- self . glob_map . insert ( directive. id , new_set) ;
1222+ fn add_to_glob_map ( & mut self , id : NodeId , name : Name ) {
1223+ if self . make_glob_map {
1224+ self . glob_map . entry ( id) . or_insert_with ( FnvHashSet ) . insert ( name) ;
1225+ }
12331226 }
12341227
12351228 /// Resolves the given module path from the given root `module_`.
@@ -1529,10 +1522,7 @@ impl<'a> Resolver<'a> {
15291522 self . populate_module_if_necessary ( module) ;
15301523 module. resolve_name ( name, namespace, use_lexical_scope) . and_then ( |binding| {
15311524 if record_used {
1532- if let NameBindingKind :: Import { directive, .. } = binding. kind {
1533- self . used_imports . insert ( ( directive. id , namespace) ) ;
1534- }
1535- self . record_use ( name, binding) ;
1525+ self . record_use ( name, namespace, binding) ;
15361526 }
15371527 Success ( binding)
15381528 } )
@@ -3154,10 +3144,10 @@ impl<'a> Resolver<'a> {
31543144 if let NameBindingKind :: Import { directive, .. } = binding. kind {
31553145 let id = directive. id ;
31563146 this. maybe_unused_trait_imports . insert ( id) ;
3147+ this. add_to_glob_map ( id, trait_name) ;
31573148 import_id = Some ( id) ;
31583149 }
31593150 add_trait_info ( & mut found_traits, trait_def_id, import_id, name) ;
3160- this. record_use ( trait_name, binding) ;
31613151 }
31623152 }
31633153 } ;
0 commit comments