From 63e72348d192dfedfb84510a88099cd6523c187b Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Wed, 16 Sep 2020 09:15:51 +0000 Subject: [PATCH] Add some docs to rustdoc::clean::inline and def_id functions Co-authored-by: Joshua Nelson --- compiler/rustc_span/src/def_id.rs | 1 + src/librustdoc/clean/inline.rs | 3 +++ 2 files changed, 4 insertions(+) diff --git a/compiler/rustc_span/src/def_id.rs b/compiler/rustc_span/src/def_id.rs index aae778217d3f1..b24ede9c53aed 100644 --- a/compiler/rustc_span/src/def_id.rs +++ b/compiler/rustc_span/src/def_id.rs @@ -159,6 +159,7 @@ impl DefId { DefId { krate: LOCAL_CRATE, index } } + /// Returns whether the item is defined in the crate currently being compiled. #[inline] pub fn is_local(self) -> bool { self.krate == LOCAL_CRATE diff --git a/src/librustdoc/clean/inline.rs b/src/librustdoc/clean/inline.rs index 31e8c32f062ab..7f64d20d8e7cd 100644 --- a/src/librustdoc/clean/inline.rs +++ b/src/librustdoc/clean/inline.rs @@ -290,10 +290,12 @@ pub fn build_ty(cx: &DocContext<'_>, did: DefId) -> Option { } } +/// Builds all inherent implementations of an ADT (struct/union/enum) or Trait item/path/reexport. pub fn build_impls(cx: &DocContext<'_>, did: DefId, attrs: Option>) -> Vec { let tcx = cx.tcx; let mut impls = Vec::new(); + // for each implementation of an item represented by `did`, build the clean::Item for that impl for &did in tcx.inherent_impls(did).iter() { build_impl(cx, did, attrs, &mut impls); } @@ -320,6 +322,7 @@ fn merge_attrs( merged_attrs.clean(cx) } +/// Builds a specific implementation of a type. The `did` could be a type method or trait method. pub fn build_impl( cx: &DocContext<'_>, did: DefId,