@@ -1207,29 +1207,22 @@ impl<'a> Resolver<'a> {
1207
1207
match ns { ValueNS => & mut self . value_ribs , TypeNS => & mut self . type_ribs }
1208
1208
}
1209
1209
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 > ) {
1212
1211
// track extern crates for unused_extern_crate lint
1213
1212
if let Some ( DefId { krate, .. } ) = binding. module ( ) . and_then ( ModuleS :: def_id) {
1214
1213
self . used_crates . insert ( krate) ;
1215
1214
}
1216
1215
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) ;
1228
1219
}
1220
+ }
1229
1221
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
+ }
1233
1226
}
1234
1227
1235
1228
/// Resolves the given module path from the given root `module_`.
@@ -1529,10 +1522,7 @@ impl<'a> Resolver<'a> {
1529
1522
self . populate_module_if_necessary ( module) ;
1530
1523
module. resolve_name ( name, namespace, use_lexical_scope) . and_then ( |binding| {
1531
1524
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) ;
1536
1526
}
1537
1527
Success ( binding)
1538
1528
} )
@@ -3154,10 +3144,10 @@ impl<'a> Resolver<'a> {
3154
3144
if let NameBindingKind :: Import { directive, .. } = binding. kind {
3155
3145
let id = directive. id ;
3156
3146
this. maybe_unused_trait_imports . insert ( id) ;
3147
+ this. add_to_glob_map ( id, trait_name) ;
3157
3148
import_id = Some ( id) ;
3158
3149
}
3159
3150
add_trait_info ( & mut found_traits, trait_def_id, import_id, name) ;
3160
- this. record_use ( trait_name, binding) ;
3161
3151
}
3162
3152
}
3163
3153
} ;
0 commit comments