@@ -1197,7 +1197,14 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
1197
1197
}
1198
1198
1199
1199
#[ inline]
1200
- fn record_import_use ( & mut self , import_id : NodeId , name : Name ) {
1200
+ fn record_import_use ( & mut self , name : Name , ns : Namespace , resolution : & ImportResolution < ' a > ) {
1201
+ let import_id = resolution. id ;
1202
+ self . used_imports . insert ( ( import_id, ns) ) ;
1203
+ match resolution. target . as_ref ( ) . and_then ( |target| target. target_module . def_id ( ) ) {
1204
+ Some ( DefId { krate, .. } ) => { self . used_crates . insert ( krate) ; }
1205
+ _ => { }
1206
+ } ;
1207
+
1201
1208
if !self . make_glob_map {
1202
1209
return ;
1203
1210
}
@@ -1596,24 +1603,12 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
1596
1603
debug ! ( "(resolving name in module) import unresolved; bailing out" ) ;
1597
1604
return Indeterminate ;
1598
1605
}
1599
- match import_resolution. target . clone ( ) {
1600
- None => {
1601
- debug ! ( "(resolving name in module) name found, but not in namespace {:?}" ,
1602
- namespace) ;
1603
- }
1604
- Some ( target) => {
1605
- debug ! ( "(resolving name in module) resolved to import" ) ;
1606
- // track used imports and extern crates as well
1607
- if record_used {
1608
- let id = import_resolution. id ;
1609
- self . used_imports . insert ( ( id, namespace) ) ;
1610
- self . record_import_use ( id, name) ;
1611
- if let Some ( DefId { krate : kid, ..} ) = target. target_module . def_id ( ) {
1612
- self . used_crates . insert ( kid) ;
1613
- }
1614
- }
1615
- return Success ( ( target, true ) ) ;
1606
+ if let Some ( target) = import_resolution. target . clone ( ) {
1607
+ debug ! ( "(resolving name in module) resolved to import" ) ;
1608
+ if record_used {
1609
+ self . record_import_use ( name, namespace, & import_resolution) ;
1616
1610
}
1611
+ return Success ( ( target, true ) ) ;
1617
1612
}
1618
1613
}
1619
1614
Some ( ..) | None => { } // Continue.
@@ -3531,13 +3526,8 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
3531
3526
} ;
3532
3527
if self . trait_item_map . contains_key ( & ( name, did) ) {
3533
3528
add_trait_info ( & mut found_traits, did, name) ;
3534
- let id = import. id ;
3535
- self . used_imports . insert ( ( id, TypeNS ) ) ;
3536
3529
let trait_name = self . get_trait_name ( did) ;
3537
- self . record_import_use ( id, trait_name) ;
3538
- if let Some ( DefId { krate : kid, ..} ) = target. target_module . def_id ( ) {
3539
- self . used_crates . insert ( kid) ;
3540
- }
3530
+ self . record_import_use ( trait_name, TypeNS , & import) ;
3541
3531
}
3542
3532
}
3543
3533
0 commit comments