@@ -1202,10 +1202,6 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
12021202 fn record_import_use ( & mut self , name : Name , ns : Namespace , resolution : & ImportResolution < ' a > ) {
12031203 let import_id = resolution. id ;
12041204 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- } ;
12091205
12101206 if !self . make_glob_map {
12111207 return ;
@@ -1299,11 +1295,6 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
12991295 // Check to see whether there are type bindings, and, if
13001296 // so, whether there is a module within.
13011297 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-
13071298 search_module = module_def;
13081299
13091300 // Keep track of the closest private module used
@@ -1573,6 +1564,12 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
15731564
15741565 if let Some ( binding) = module_. get_child ( name, namespace) {
15751566 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+ }
15761573 return Success ( ( Target :: new ( module_, binding, Shadowable :: Never ) , false ) ) ;
15771574 }
15781575
@@ -2923,9 +2920,6 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
29232920 }
29242921 _ => return None ,
29252922 } ;
2926- if let Some ( DefId { krate : kid, ..} ) = containing_module. def_id ( ) {
2927- self . used_crates . insert ( kid) ;
2928- }
29292923 return Some ( def) ;
29302924 }
29312925
0 commit comments