@@ -157,6 +157,7 @@ pub struct Cache {
157
157
priv parent_stack : ~[ ast:: NodeId ] ,
158
158
priv search_index : ~[ IndexItem ] ,
159
159
priv privmod : bool ,
160
+ priv public_items : HashSet < ast:: NodeId > ,
160
161
}
161
162
162
163
/// Helper struct to render all source code to HTML pages
@@ -231,18 +232,23 @@ pub fn run(mut krate: clean::Crate, dst: Path) -> io::IoResult<()> {
231
232
}
232
233
233
234
// Crawl the crate to build various caches used for the output
234
- let mut cache = Cache {
235
- impls : HashMap :: new ( ) ,
236
- typarams : HashMap :: new ( ) ,
237
- paths : HashMap :: new ( ) ,
238
- traits : HashMap :: new ( ) ,
239
- implementors : HashMap :: new ( ) ,
240
- stack : ~[ ] ,
241
- parent_stack : ~[ ] ,
242
- search_index : ~[ ] ,
243
- extern_locations : HashMap :: new ( ) ,
244
- privmod : false ,
245
- } ;
235
+ let mut cache = local_data:: get ( :: analysiskey, |analysis| {
236
+ let public_items = analysis. map ( |a| a. public_items . clone ( ) ) ;
237
+ let public_items = public_items. unwrap_or ( HashSet :: new ( ) ) ;
238
+ Cache {
239
+ impls : HashMap :: new ( ) ,
240
+ typarams : HashMap :: new ( ) ,
241
+ paths : HashMap :: new ( ) ,
242
+ traits : HashMap :: new ( ) ,
243
+ implementors : HashMap :: new ( ) ,
244
+ stack : ~[ ] ,
245
+ parent_stack : ~[ ] ,
246
+ search_index : ~[ ] ,
247
+ extern_locations : HashMap :: new ( ) ,
248
+ privmod : false ,
249
+ public_items : public_items,
250
+ }
251
+ } ) ;
246
252
cache. stack . push ( krate. name . clone ( ) ) ;
247
253
krate = cache. fold_crate ( krate) ;
248
254
@@ -566,7 +572,16 @@ impl DocFolder for Cache {
566
572
clean:: TypedefItem ( ..) | clean:: TraitItem ( ..) |
567
573
clean:: FunctionItem ( ..) | clean:: ModuleItem ( ..) |
568
574
clean:: ForeignFunctionItem ( ..) => {
569
- self . paths . insert ( item. id , ( self . stack . clone ( ) , shortty ( & item) ) ) ;
575
+ // Reexported items mean that the same id can show up twice in
576
+ // the rustdoc ast that we're looking at. We know, however, that
577
+ // a reexported item doesn't show up in the `public_items` map,
578
+ // so we can skip inserting into the paths map if there was
579
+ // already an entry present and we're not a public item.
580
+ if !self . paths . contains_key ( & item. id ) ||
581
+ self . public_items . contains ( & item. id ) {
582
+ self . paths . insert ( item. id ,
583
+ ( self . stack . clone ( ) , shortty ( & item) ) ) ;
584
+ }
570
585
}
571
586
// link variants to their parent enum because pages aren't emitted
572
587
// for each variant
0 commit comments