@@ -171,7 +171,7 @@ impl<'a> CrateLoader<'a> {
171171 name : name,
172172 id : i. id ,
173173 dep_kind : if attr:: contains_name ( & i. attrs , "no_link" ) {
174- DepKind :: MacrosOnly
174+ DepKind :: UnexportedMacrosOnly
175175 } else {
176176 DepKind :: Explicit
177177 } ,
@@ -350,7 +350,7 @@ impl<'a> CrateLoader<'a> {
350350 } ;
351351
352352 self . load ( & mut locate_ctxt) . or_else ( || {
353- dep_kind = DepKind :: MacrosOnly ;
353+ dep_kind = DepKind :: UnexportedMacrosOnly ;
354354
355355 let mut proc_macro_locator = locator:: Context {
356356 target : & self . sess . host ,
@@ -373,7 +373,7 @@ impl<'a> CrateLoader<'a> {
373373 LoadResult :: Previous ( cnum) => {
374374 let data = self . cstore . get_crate_data ( cnum) ;
375375 if data. root . macro_derive_registrar . is_some ( ) {
376- dep_kind = DepKind :: MacrosOnly ;
376+ dep_kind = DepKind :: UnexportedMacrosOnly ;
377377 }
378378 data. dep_kind . set ( cmp:: max ( data. dep_kind . get ( ) , dep_kind) ) ;
379379 ( cnum, data)
@@ -460,28 +460,23 @@ impl<'a> CrateLoader<'a> {
460460 return cstore:: CrateNumMap :: new ( ) ;
461461 }
462462
463- // The map from crate numbers in the crate we're resolving to local crate
464- // numbers
465- let deps = crate_root . crate_deps . decode ( metadata ) ;
466- let map : FxHashMap < _ , _ > = deps . enumerate ( ) . map ( |( crate_num , dep) | {
463+ // The map from crate numbers in the crate we're resolving to local crate numbers.
464+ // We map 0 and all other holes in the map to our parent crate. The "additional"
465+ // self-dependencies should be harmless.
466+ :: std :: iter :: once ( krate ) . chain ( crate_root . crate_deps . decode ( metadata ) . map ( |dep| {
467467 debug ! ( "resolving dep crate {} hash: `{}`" , dep. name, dep. hash) ;
468+ if dep. kind == DepKind :: UnexportedMacrosOnly {
469+ return krate;
470+ }
468471 let dep_kind = match dep_kind {
469472 DepKind :: MacrosOnly => DepKind :: MacrosOnly ,
470473 _ => dep. kind ,
471474 } ;
472475 let ( local_cnum, ..) = self . resolve_crate (
473476 root, dep. name , dep. name , Some ( & dep. hash ) , span, PathKind :: Dependency , dep_kind,
474477 ) ;
475- ( CrateNum :: new ( crate_num + 1 ) , local_cnum)
476- } ) . collect ( ) ;
477-
478- let max_cnum = map. values ( ) . cloned ( ) . max ( ) . map ( |cnum| cnum. as_u32 ( ) ) . unwrap_or ( 0 ) ;
479-
480- // we map 0 and all other holes in the map to our parent crate. The "additional"
481- // self-dependencies should be harmless.
482- ( 0 ..max_cnum+1 ) . map ( |cnum| {
483- map. get ( & CrateNum :: from_u32 ( cnum) ) . cloned ( ) . unwrap_or ( krate)
484- } ) . collect ( )
478+ local_cnum
479+ } ) ) . collect ( )
485480 }
486481
487482 fn read_extension_crate ( & mut self , span : Span , info : & ExternCrateInfo ) -> ExtensionCrate {
@@ -614,7 +609,7 @@ impl<'a> CrateLoader<'a> {
614609 name : Symbol :: intern ( name) ,
615610 ident : Symbol :: intern ( name) ,
616611 id : ast:: DUMMY_NODE_ID ,
617- dep_kind : DepKind :: MacrosOnly ,
612+ dep_kind : DepKind :: UnexportedMacrosOnly ,
618613 } ) ;
619614
620615 if ekrate. target_only {
0 commit comments