Change:
cx.krate(krate) } <ins> /// Build the search index from the collected metadata </ins> fn build_index(krate: &clean::Crate, cache: &mut Cache) -> String { <del> // Build the search index from the collected metadata </del> let mut nodeid_to_pathid = HashMap::new(); <del> let mut pathid_to_nodeid = Vec::new(); { let Cache { ref mut search_index, ref orphan_methods, ref mut paths, .. } = *cache; // Attach all orphan methods to the type's definition if the type // has since been learned. for &(did, ref item) in orphan_methods { match paths.get(&did) { Some(&(ref fqp, _)) => { // Needed to determine `self` type. let parent_basename = Some(fqp[fqp.len() - 1].clone()); search_index.push(IndexItem { ty: shortty(item), name: item.name.clone().unwrap(), path: fqp[..fqp.len() - 1].join("::"), desc: Escape(&shorter(item.doc_value())).to_string(), parent: Some(did), search_type: get_index_search_type(&item, parent_basename), }); }, None => {} } } // Reduce `NodeId` in paths into smaller sequential numbers, // and prune the paths that do not appear in the index. for item in search_index.iter() { match item.parent { Some(nodeid) => { if !nodeid_to_pathid.contains_key(&nodeid) { let pathid = pathid_to_nodeid.len(); nodeid_to_pathid.insert(nodeid, pathid); pathid_to_nodeid.push(nodeid); } } None => {} } </del> <ins> let mut crate_items = Vec::with_capacity(cache.search_index.len()); let mut crate_paths = Vec::<Json>::new(); let Cache { ref mut search_index, ref orphan_methods, ref mut paths, .. } = *cache; // Attach all orphan methods to the type's definition if the type // has since been learned. for &(did, ref item) in orphan_methods { match paths.get(&did) { Some(&(ref fqp, _)) => { // Needed to determine `self` type. let parent_basename = Some(fqp[fqp.len() - 1].clone()); search_index.push(IndexItem { ty: shortty(item), name: item.name.clone().unwrap(), path: fqp[..fqp.len() - 1].join("::"), desc: Escape(&shorter(item.doc_value())).to_string(), parent: Some(did), parent_idx: None, search_type: get_index_search_type(&item, parent_basename), }); }, None => {} </ins> } <del> assert_eq!(nodeid_to_pathid.len(), pathid_to_nodeid.len()); </del> } <del> // Collect the index into a string let mut w = io::Cursor::new(Vec::new()); write!(&mut w, r#"searchIndex['{}'] = {{"items":["#, krate.name).unwrap(); </del> <ins> // Reduce `NodeId` in paths into smaller sequential numbers, // and prune the paths that do not appear in the index. let mut lastpath = String::new(); let mut lastpathid = 0usize; </ins> <del> let mut lastpath = "".to_string(); for (i, item) in cache.search_index.iter().enumerate() { // Omit the path if it is same to that of the prior item. let path; if lastpath == item.path { path = ""; } else { lastpath = item.path.to_string(); path = &item.path; }; </del> <ins> for item in search_index { item.parent_idx = item.parent.map(|nodeid| { if nodeid_to_pathid.contains_key(&nodeid) { *nodeid_to_pathid.get(&nodeid).unwrap() } else { let pathid = lastpathid; nodeid_to_pathid.insert(nodeid, pathid); lastpathid += 1; </ins> <del> if i > 0 { write!(&mut w, ",").unwrap(); } write!(&mut w, r#"[{},"{}","{}",{}"#, item.ty as usize, item.name, path, item.desc.to_json().to_string()).unwrap(); match item.parent { Some(nodeid) => { let pathid = *nodeid_to_pathid.get(&nodeid).unwrap(); write!(&mut w, ",{}", pathid).unwrap(); </del> <ins> let &(ref fqp, short) = paths.get(&nodeid).unwrap(); crate_paths.push(((short as usize), fqp.last().unwrap().clone()).to_json()); pathid </ins> } <del> None => write!(&mut w, ",null").unwrap() } match item.search_type { Some(ref t) => write!(&mut w, ",{}", t).unwrap(), None => write!(&mut w, ",null").unwrap() } write!(&mut w, "]").unwrap(); } write!(&mut w, r#"],"paths":["#).unwrap(); </del> <ins> }); </ins> <del> for (i, &did) in pathid_to_nodeid.iter().enumerate() { let &(ref fqp, short) = cache.paths.get(&did).unwrap(); if i > 0 { write!(&mut w, ",").unwrap(); </del> <ins> // Omit the parent path if it is same to that of the prior item. if lastpath == item.path { item.path.clear(); } else { lastpath = item.path.clone(); </ins> } <del> write!(&mut w, r#"[{},"{}"]"#, short as usize, *fqp.last().unwrap()).unwrap(); </del> <ins> crate_items.push(item.to_json()); </ins> } <del> write!(&mut w, "]}};").unwrap(); </del> <ins> let crate_doc = krate.module.as_ref().map(|module| { Escape(&shorter(module.doc_value())).to_string() }).unwrap_or(String::new()); </ins> <del> String::from_utf8(w.into_inner()).unwrap() </del> <ins> let mut crate_data = BTreeMap::new(); crate_data.insert("doc".to_owned(), Json::String(crate_doc)); crate_data.insert("items".to_owned(), Json::Array(crate_items)); crate_data.insert("paths".to_owned(), Json::Array(crate_paths)); // Collect the index into a string format!("searchIndex[{}] = {};", as_json(&krate.name), Json::Object(crate_data)) </ins> } fn write_shared(cx: &Context,

Discussion:
E.g. doesn't show the crate.
ccing myself, will have a look at this in the next week or so.
cc me
Triage: searching for libc doesn't show libc.
Hmm, I deliberately removed the search-index entry in because it was .