Skip to content

Commit b60f08b

Browse files
tomjakubowskiGuillaumeGomez
authored andcommitted
rustdoc: NodeId is now DefId
1 parent 320ada6 commit b60f08b

File tree

1 file changed

+11
-16
lines changed

1 file changed

+11
-16
lines changed

src/librustdoc/html/render/cache.rs

+11-16
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ crate struct Cache {
4343
/// found on that implementation.
4444
pub impls: FxHashMap<DefId, Vec<Impl>>,
4545

46-
/// Maintains a mapping of local crate `NodeId`s to the fully qualified name
46+
/// Maintains a mapping of local crate `DefId`s to the fully qualified name
4747
/// and "short type description" of that node. This is used when generating
4848
/// URLs when a type is being linked to. External paths are not located in
4949
/// this map because the `External` type itself has all the information
@@ -358,6 +358,7 @@ impl DocFolder for Cache {
358358
| clean::ForeignTypeItem
359359
| clean::MacroItem(..)
360360
| clean::ProcMacroItem(..)
361+
| clean::VariantItem(..)
361362
if !self.stripped_mod =>
362363
{
363364
// Re-exported items mean that the same id can show up twice
@@ -373,13 +374,6 @@ impl DocFolder for Cache {
373374
}
374375
self.add_aliases(&item);
375376
}
376-
// Link variants to their parent enum because pages aren't emitted
377-
// for each variant.
378-
clean::VariantItem(..) if !self.stripped_mod => {
379-
let mut stack = self.stack.clone();
380-
stack.pop();
381-
self.paths.insert(item.def_id, (stack, ItemType::Enum));
382-
}
383377

384378
clean::PrimitiveItem(..) => {
385379
self.add_aliases(&item);
@@ -396,7 +390,8 @@ impl DocFolder for Cache {
396390
| clean::EnumItem(..)
397391
| clean::ForeignTypeItem
398392
| clean::StructItem(..)
399-
| clean::UnionItem(..) => {
393+
| clean::UnionItem(..)
394+
| clean::VariantItem(..) => {
400395
self.parent_stack.push(item.def_id);
401396
self.parent_is_trait_impl = false;
402397
true
@@ -564,7 +559,7 @@ fn extern_location(
564559

565560
/// Builds the search index from the collected metadata
566561
fn build_index(krate: &clean::Crate, cache: &mut Cache) -> String {
567-
let mut nodeid_to_pathid = FxHashMap::default();
562+
let mut defid_to_pathid = FxHashMap::default();
568563
let mut crate_items = Vec::with_capacity(cache.search_index.len());
569564
let mut crate_paths = vec![];
570565

@@ -586,21 +581,21 @@ fn build_index(krate: &clean::Crate, cache: &mut Cache) -> String {
586581
}
587582
}
588583

589-
// Reduce `NodeId` in paths into smaller sequential numbers,
584+
// Reduce `DefId` in paths into smaller sequential numbers,
590585
// and prune the paths that do not appear in the index.
591586
let mut lastpath = String::new();
592587
let mut lastpathid = 0usize;
593588

594589
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).expect("no pathid")
590+
item.parent_idx = item.parent.map(|defid| {
591+
if defid_to_pathid.contains_key(&defid) {
592+
*defid_to_pathid.get(&defid).expect("no pathid")
598593
} else {
599594
let pathid = lastpathid;
600-
nodeid_to_pathid.insert(nodeid, pathid);
595+
defid_to_pathid.insert(defid, pathid);
601596
lastpathid += 1;
602597

603-
let &(ref fqp, short) = paths.get(&nodeid).unwrap();
598+
let &(ref fqp, short) = paths.get(&defid).unwrap();
604599
crate_paths.push((short, fqp.last().unwrap().clone()));
605600
pathid
606601
}

0 commit comments

Comments
 (0)