@@ -1202,10 +1202,6 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
1202
1202
fn record_import_use ( & mut self , name : Name , ns : Namespace , resolution : & ImportResolution < ' a > ) {
1203
1203
let import_id = resolution. id ;
1204
1204
self . used_imports . insert ( ( import_id, ns) ) ;
1205
- match resolution. target . as_ref ( ) . and_then ( |target| target. target_module . def_id ( ) ) {
1206
- Some ( DefId { krate, .. } ) => { self . used_crates . insert ( krate) ; }
1207
- _ => { }
1208
- } ;
1209
1205
1210
1206
if !self . make_glob_map {
1211
1207
return ;
@@ -1299,11 +1295,6 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
1299
1295
// Check to see whether there are type bindings, and, if
1300
1296
// so, whether there is a module within.
1301
1297
if let Some ( module_def) = target. binding . module ( ) {
1302
- // track extern crates for unused_extern_crate lint
1303
- if let Some ( did) = module_def. def_id ( ) {
1304
- self . used_crates . insert ( did. krate ) ;
1305
- }
1306
-
1307
1298
search_module = module_def;
1308
1299
1309
1300
// Keep track of the closest private module used
@@ -1573,6 +1564,12 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
1573
1564
1574
1565
if let Some ( binding) = module_. get_child ( name, namespace) {
1575
1566
debug ! ( "(resolving name in module) found node as child" ) ;
1567
+ if binding. is_extern_crate ( ) {
1568
+ // track the extern crate as used.
1569
+ if let Some ( DefId { krate, .. } ) = binding. module ( ) . unwrap ( ) . def_id ( ) {
1570
+ self . used_crates . insert ( krate) ;
1571
+ }
1572
+ }
1576
1573
return Success ( ( Target :: new ( module_, binding, Shadowable :: Never ) , false ) ) ;
1577
1574
}
1578
1575
@@ -2923,9 +2920,6 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
2923
2920
}
2924
2921
_ => return None ,
2925
2922
} ;
2926
- if let Some ( DefId { krate : kid, ..} ) = containing_module. def_id ( ) {
2927
- self . used_crates . insert ( kid) ;
2928
- }
2929
2923
return Some ( def) ;
2930
2924
}
2931
2925
0 commit comments