about summary refs log tree commit diff
path: root/src/librustdoc/formats
diff options
context:
space:
mode:
authorDylan DPC <99973273+Dylan-DPC@users.noreply.github.com>2022-04-19 14:43:21 +0200
committerGitHub <noreply@github.com>2022-04-19 14:43:21 +0200
commit9fad214593e87f151b8f09ff0cda9cd52372d037 (patch)
treec333bb0ef5940f836e2151ca3d87986d199e30d9 /src/librustdoc/formats
parent036d200d1c7634f2a65e0dd28b094aa1220bbce0 (diff)
parent07ee0317638cf1f290a8dace1c7ccc8fea16a236 (diff)
downloadrust-9fad214593e87f151b8f09ff0cda9cd52372d037.tar.gz
rust-9fad214593e87f151b8f09ff0cda9cd52372d037.zip
Rollup merge of #96142 - cjgillot:no-crate-def-index, r=petrochenkov
Stop using CRATE_DEF_INDEX outside of metadata encoding.

`CRATE_DEF_ID` and `CrateNum::as_def_id` are almost always what we want.  We should not manipulate raw `DefIndex` outside of metadata encoding.
Diffstat (limited to 'src/librustdoc/formats')
-rw-r--r--src/librustdoc/formats/cache.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/librustdoc/formats/cache.rs b/src/librustdoc/formats/cache.rs
index 06e7c9e763d..b4d2772b31d 100644
--- a/src/librustdoc/formats/cache.rs
+++ b/src/librustdoc/formats/cache.rs
@@ -1,7 +1,7 @@
 use std::mem;
 
 use rustc_data_structures::fx::{FxHashMap, FxHashSet};
-use rustc_hir::def_id::{CrateNum, DefId, CRATE_DEF_INDEX};
+use rustc_hir::def_id::{CrateNum, DefId};
 use rustc_middle::middle::privacy::AccessLevels;
 use rustc_middle::ty::TyCtxt;
 use rustc_span::{sym, Symbol};
@@ -302,7 +302,7 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
                     // A crate has a module at its root, containing all items,
                     // which should not be indexed. The crate-item itself is
                     // inserted later on when serializing the search-index.
-                    if item.item_id.index().map_or(false, |idx| idx != CRATE_DEF_INDEX) {
+                    if item.item_id.as_def_id().map_or(false, |idx| !idx.is_crate_root()) {
                         let desc = item.doc_value().map_or_else(String::new, |x| {
                             short_markdown_summary(x.as_str(), &item.link_names(self.cache))
                         });