@@ -277,7 +277,7 @@ impl DocFolder for Cache {
277277 | clean:: StructFieldItem ( ..)
278278 | clean:: VariantItem ( ..) => (
279279 (
280- Some ( * self . parent_stack . last ( ) . unwrap ( ) ) ,
280+ Some ( * self . parent_stack . last ( ) . expect ( "parent_stack is empty" ) ) ,
281281 Some ( & self . stack [ ..self . stack . len ( ) - 1 ] ) ,
282282 ) ,
283283 false ,
@@ -286,7 +286,7 @@ impl DocFolder for Cache {
286286 if self . parent_stack . is_empty ( ) {
287287 ( ( None , None ) , false )
288288 } else {
289- let last = self . parent_stack . last ( ) . unwrap ( ) ;
289+ let last = self . parent_stack . last ( ) . expect ( "parent_stack is empty 2" ) ;
290290 let did = * last;
291291 let path = match self . paths . get ( & did) {
292292 // The current stack not necessarily has correlation
@@ -468,7 +468,7 @@ impl DocFolder for Cache {
468468 self . impls . entry ( did) . or_insert ( vec ! [ ] ) . push ( impl_item. clone ( ) ) ;
469469 }
470470 } else {
471- let trait_did = impl_item. trait_did ( ) . unwrap ( ) ;
471+ let trait_did = impl_item. trait_did ( ) . expect ( "no trait did" ) ;
472472 self . orphan_trait_impls . push ( ( trait_did, dids, impl_item) ) ;
473473 }
474474 None
@@ -478,10 +478,10 @@ impl DocFolder for Cache {
478478 } ) ;
479479
480480 if pushed {
481- self . stack . pop ( ) . unwrap ( ) ;
481+ self . stack . pop ( ) . expect ( "stack already empty" ) ;
482482 }
483483 if parent_pushed {
484- self . parent_stack . pop ( ) . unwrap ( ) ;
484+ self . parent_stack . pop ( ) . expect ( "parent stack already empty" ) ;
485485 }
486486 self . stripped_mod = orig_stripped_mod;
487487 self . parent_is_trait_impl = orig_parent_is_trait_impl;
@@ -574,6 +574,9 @@ fn build_index(krate: &clean::Crate, cache: &mut Cache) -> String {
574574 // has since been learned.
575575 for & ( did, ref item) in orphan_impl_items {
576576 if let Some ( & ( ref fqp, _) ) = paths. get ( & did) {
577+ if item. name . is_none ( ) { // this is most likely from a typedef
578+ continue ;
579+ }
577580 search_index. push ( IndexItem {
578581 ty : item. type_ ( ) ,
579582 name : item. name . clone ( ) . unwrap ( ) ,
@@ -592,19 +595,25 @@ fn build_index(krate: &clean::Crate, cache: &mut Cache) -> String {
592595 let mut lastpathid = 0usize ;
593596
594597 for item in search_index {
595- item. parent_idx = item. parent . map ( |nodeid| {
596- if nodeid_to_pathid. contains_key ( & nodeid) {
597- * nodeid_to_pathid. get ( & nodeid) . unwrap ( )
598- } else {
599- let pathid = lastpathid;
600- nodeid_to_pathid. insert ( nodeid, pathid) ;
601- lastpathid += 1 ;
598+ item. parent_idx = match item. parent {
599+ Some ( nodeid) => {
600+ Some ( if nodeid_to_pathid. contains_key ( & nodeid) {
601+ * nodeid_to_pathid. get ( & nodeid) . expect ( "no pathid" )
602+ } else {
603+ let pathid = lastpathid;
604+ nodeid_to_pathid. insert ( nodeid, pathid) ;
605+ lastpathid += 1 ;
602606
603- let & ( ref fqp, short) = paths. get ( & nodeid) . unwrap ( ) ;
604- crate_paths. push ( ( short, fqp. last ( ) . unwrap ( ) . clone ( ) ) ) ;
605- pathid
607+ if let Some ( & ( ref fqp, short) ) = paths. get ( & nodeid) {
608+ crate_paths. push ( ( short, fqp. last ( ) . expect ( "no fqp" ) . clone ( ) ) ) ;
609+ } else {
610+ continue
611+ }
612+ pathid
613+ } )
606614 }
607- } ) ;
615+ None => None ,
616+ } ;
608617
609618 // Omit the parent path if it is same to that of the prior item.
610619 if lastpath == item. path {
@@ -639,7 +648,7 @@ fn build_index(krate: &clean::Crate, cache: &mut Cache) -> String {
639648 items: crate_items,
640649 paths: crate_paths,
641650 } )
642- . unwrap ( )
651+ . expect ( "failed serde conversion" )
643652 )
644653}
645654
0 commit comments