@@ -171,7 +171,7 @@ impl<'a> CrateLoader<'a> {
171
171
name : name,
172
172
id : i. id ,
173
173
dep_kind : if attr:: contains_name ( & i. attrs , "no_link" ) {
174
- DepKind :: MacrosOnly
174
+ DepKind :: UnexportedMacrosOnly
175
175
} else {
176
176
DepKind :: Explicit
177
177
} ,
@@ -350,7 +350,7 @@ impl<'a> CrateLoader<'a> {
350
350
} ;
351
351
352
352
self . load ( & mut locate_ctxt) . or_else ( || {
353
- dep_kind = DepKind :: MacrosOnly ;
353
+ dep_kind = DepKind :: UnexportedMacrosOnly ;
354
354
355
355
let mut proc_macro_locator = locator:: Context {
356
356
target : & self . sess . host ,
@@ -373,7 +373,7 @@ impl<'a> CrateLoader<'a> {
373
373
LoadResult :: Previous ( cnum) => {
374
374
let data = self . cstore . get_crate_data ( cnum) ;
375
375
if data. root . macro_derive_registrar . is_some ( ) {
376
- dep_kind = DepKind :: MacrosOnly ;
376
+ dep_kind = DepKind :: UnexportedMacrosOnly ;
377
377
}
378
378
data. dep_kind . set ( cmp:: max ( data. dep_kind . get ( ) , dep_kind) ) ;
379
379
( cnum, data)
@@ -460,28 +460,23 @@ impl<'a> CrateLoader<'a> {
460
460
return cstore:: CrateNumMap :: new ( ) ;
461
461
}
462
462
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| {
467
467
debug ! ( "resolving dep crate {} hash: `{}`" , dep. name, dep. hash) ;
468
+ if dep. kind == DepKind :: UnexportedMacrosOnly {
469
+ return krate;
470
+ }
468
471
let dep_kind = match dep_kind {
469
472
DepKind :: MacrosOnly => DepKind :: MacrosOnly ,
470
473
_ => dep. kind ,
471
474
} ;
472
475
let ( local_cnum, ..) = self . resolve_crate (
473
476
root, dep. name , dep. name , Some ( & dep. hash ) , span, PathKind :: Dependency , dep_kind,
474
477
) ;
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 ( )
485
480
}
486
481
487
482
fn read_extension_crate ( & mut self , span : Span , info : & ExternCrateInfo ) -> ExtensionCrate {
@@ -614,7 +609,7 @@ impl<'a> CrateLoader<'a> {
614
609
name : Symbol :: intern ( name) ,
615
610
ident : Symbol :: intern ( name) ,
616
611
id : ast:: DUMMY_NODE_ID ,
617
- dep_kind : DepKind :: MacrosOnly ,
612
+ dep_kind : DepKind :: UnexportedMacrosOnly ,
618
613
} ) ;
619
614
620
615
if ekrate. target_only {
0 commit comments