diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:43 +0000 |
commit | 3e3e70d529d8c7d7c4d7bc4fefc9f109393b9245 (patch) | |
tree | daf049b282ab10e8c3d03e409b3cd84ff3f7690c /src/librustdoc/json/mod.rs | |
parent | Adding debian version 1.68.2+dfsg1-1. (diff) | |
download | rustc-3e3e70d529d8c7d7c4d7bc4fefc9f109393b9245.tar.xz rustc-3e3e70d529d8c7d7c4d7bc4fefc9f109393b9245.zip |
Merging upstream version 1.69.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/librustdoc/json/mod.rs')
-rw-r--r-- | src/librustdoc/json/mod.rs | 34 |
1 files changed, 15 insertions, 19 deletions
diff --git a/src/librustdoc/json/mod.rs b/src/librustdoc/json/mod.rs index 1196f944f..08bceb59c 100644 --- a/src/librustdoc/json/mod.rs +++ b/src/librustdoc/json/mod.rs @@ -13,8 +13,8 @@ use std::io::{BufWriter, Write}; use std::path::PathBuf; use std::rc::Rc; -use rustc_data_structures::fx::{FxHashMap, FxHashSet}; -use rustc_hir::def_id::DefId; +use rustc_data_structures::fx::FxHashMap; +use rustc_hir::def_id::{DefId, DefIdSet}; use rustc_middle::ty::TyCtxt; use rustc_session::Session; use rustc_span::def_id::LOCAL_CRATE; @@ -28,7 +28,7 @@ use crate::docfs::PathError; use crate::error::Error; use crate::formats::cache::Cache; use crate::formats::FormatRenderer; -use crate::json::conversions::{from_item_id, from_item_id_with_name, IntoWithTcx}; +use crate::json::conversions::{id_from_item, id_from_item_default, IntoWithTcx}; use crate::{clean, try_err}; #[derive(Clone)] @@ -40,7 +40,7 @@ pub(crate) struct JsonRenderer<'tcx> { /// The directory where the blob will be written to. out_path: PathBuf, cache: Rc<Cache>, - imported_items: FxHashSet<DefId>, + imported_items: DefIdSet, } impl<'tcx> JsonRenderer<'tcx> { @@ -58,7 +58,7 @@ impl<'tcx> JsonRenderer<'tcx> { .map(|i| { let item = &i.impl_item; self.item(item.clone()).unwrap(); - from_item_id_with_name(item.item_id, self.tcx, item.name) + id_from_item(&item, self.tcx) }) .collect() }) @@ -80,17 +80,16 @@ impl<'tcx> JsonRenderer<'tcx> { // document primitive items in an arbitrary crate by using // `doc(primitive)`. let mut is_primitive_impl = false; - if let clean::types::ItemKind::ImplItem(ref impl_) = *item.kind { - if impl_.trait_.is_none() { - if let clean::types::Type::Primitive(_) = impl_.for_ { - is_primitive_impl = true; - } - } + if let clean::types::ItemKind::ImplItem(ref impl_) = *item.kind && + impl_.trait_.is_none() && + let clean::types::Type::Primitive(_) = impl_.for_ + { + is_primitive_impl = true; } if item.item_id.is_local() || is_primitive_impl { self.item(item.clone()).unwrap(); - Some(from_item_id_with_name(item.item_id, self.tcx, item.name)) + Some(id_from_item(&item, self.tcx)) } else { None } @@ -151,7 +150,6 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> { // Flatten items that recursively store other items item.kind.inner_items().for_each(|i| self.item(i.clone()).unwrap()); - let name = item.name; let item_id = item.item_id; if let Some(mut new_item) = self.convert_item(item) { let can_be_ignored = match new_item.inner { @@ -194,10 +192,7 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> { | types::ItemEnum::Macro(_) | types::ItemEnum::ProcMacro(_) => false, }; - let removed = self - .index - .borrow_mut() - .insert(from_item_id_with_name(item_id, self.tcx, name), new_item.clone()); + let removed = self.index.borrow_mut().insert(new_item.id.clone(), new_item.clone()); // FIXME(adotinthevoid): Currently, the index is duplicated. This is a sanity check // to make sure the items are unique. The main place this happens is when an item, is @@ -208,6 +203,7 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> { if !can_be_ignored { assert_eq!(old_item, new_item); } + trace!("replaced {:?}\nwith {:?}", old_item, new_item); } } @@ -222,7 +218,7 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> { fn after_krate(&mut self) -> Result<(), Error> { debug!("Done with crate"); - debug!("Adding Primitve impls"); + debug!("Adding Primitive impls"); for primitive in Rc::clone(&self.cache).primitive_locations.values() { self.get_impls(*primitive); } @@ -247,7 +243,7 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> { .chain(&self.cache.external_paths) .map(|(&k, &(ref path, kind))| { ( - from_item_id(k.into(), self.tcx), + id_from_item_default(k.into(), self.tcx), types::ItemSummary { crate_id: k.krate.as_u32(), path: path.iter().map(|s| s.to_string()).collect(), |