about summary refs log tree commit diff
path: root/src/librustdoc
diff options
context:
space:
mode:
authorTom Jakubowski <tom@crystae.net>2019-09-23 18:39:55 -0700
committerGuillaume Gomez <guillaume1.gomez@gmail.com>2020-01-30 13:38:25 +0100
commitb60f08bd6d3fbe784eb47a57e0c41954454af3dd (patch)
tree33c998342ad86f9e2538d73efc6044bdd86b9b6c /src/librustdoc
parent320ada6479b3e29c7d9a66bc56ac44c2d2b57566 (diff)
downloadrust-b60f08bd6d3fbe784eb47a57e0c41954454af3dd.tar.gz
rust-b60f08bd6d3fbe784eb47a57e0c41954454af3dd.zip
rustdoc: NodeId is now DefId
Diffstat (limited to 'src/librustdoc')
-rw-r--r--src/librustdoc/html/render/cache.rs27
1 files changed, 11 insertions, 16 deletions
diff --git a/src/librustdoc/html/render/cache.rs b/src/librustdoc/html/render/cache.rs
index f1f83acdda5..3acfb82fe78 100644
--- a/src/librustdoc/html/render/cache.rs
+++ b/src/librustdoc/html/render/cache.rs
@@ -43,7 +43,7 @@ crate struct Cache {
     /// found on that implementation.
     pub impls: FxHashMap<DefId, Vec<Impl>>,
 
-    /// Maintains a mapping of local crate `NodeId`s to the fully qualified name
+    /// Maintains a mapping of local crate `DefId`s to the fully qualified name
     /// and "short type description" of that node. This is used when generating
     /// URLs when a type is being linked to. External paths are not located in
     /// this map because the `External` type itself has all the information
@@ -358,6 +358,7 @@ impl DocFolder for Cache {
             | clean::ForeignTypeItem
             | clean::MacroItem(..)
             | clean::ProcMacroItem(..)
+            | clean::VariantItem(..)
                 if !self.stripped_mod =>
             {
                 // Re-exported items mean that the same id can show up twice
@@ -373,13 +374,6 @@ impl DocFolder for Cache {
                 }
                 self.add_aliases(&item);
             }
-            // Link variants to their parent enum because pages aren't emitted
-            // for each variant.
-            clean::VariantItem(..) if !self.stripped_mod => {
-                let mut stack = self.stack.clone();
-                stack.pop();
-                self.paths.insert(item.def_id, (stack, ItemType::Enum));
-            }
 
             clean::PrimitiveItem(..) => {
                 self.add_aliases(&item);
@@ -396,7 +390,8 @@ impl DocFolder for Cache {
             | clean::EnumItem(..)
             | clean::ForeignTypeItem
             | clean::StructItem(..)
-            | clean::UnionItem(..) => {
+            | clean::UnionItem(..)
+            | clean::VariantItem(..) => {
                 self.parent_stack.push(item.def_id);
                 self.parent_is_trait_impl = false;
                 true
@@ -564,7 +559,7 @@ fn extern_location(
 
 /// Builds the search index from the collected metadata
 fn build_index(krate: &clean::Crate, cache: &mut Cache) -> String {
-    let mut nodeid_to_pathid = FxHashMap::default();
+    let mut defid_to_pathid = FxHashMap::default();
     let mut crate_items = Vec::with_capacity(cache.search_index.len());
     let mut crate_paths = vec![];
 
@@ -586,21 +581,21 @@ fn build_index(krate: &clean::Crate, cache: &mut Cache) -> String {
         }
     }
 
-    // Reduce `NodeId` in paths into smaller sequential numbers,
+    // Reduce `DefId` 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;
 
     for item in search_index {
-        item.parent_idx = item.parent.map(|nodeid| {
-            if nodeid_to_pathid.contains_key(&nodeid) {
-                *nodeid_to_pathid.get(&nodeid).expect("no pathid")
+        item.parent_idx = item.parent.map(|defid| {
+            if defid_to_pathid.contains_key(&defid) {
+                *defid_to_pathid.get(&defid).expect("no pathid")
             } else {
                 let pathid = lastpathid;
-                nodeid_to_pathid.insert(nodeid, pathid);
+                defid_to_pathid.insert(defid, pathid);
                 lastpathid += 1;
 
-                let &(ref fqp, short) = paths.get(&nodeid).unwrap();
+                let &(ref fqp, short) = paths.get(&defid).unwrap();
                 crate_paths.push((short, fqp.last().unwrap().clone()));
                 pathid
             }