Skip to content

Commit bd36c4f

Browse files
committed
Address the easy review comments
- Fix wrong link - Don't re-implement `span_with_body`
1 parent dd11100 commit bd36c4f

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

src/librustdoc/clean/inline.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ crate fn try_inline(
125125

126126
cx.renderinfo.borrow_mut().inlined.insert(did);
127127
let what_rustc_thinks = clean::Item::from_def_id_and_parts(did, Some(name), inner, cx);
128-
ret.push(clean::Item { attrs, visibility: clean::Public, ..what_rustc_thinks });
128+
ret.push(clean::Item { attrs, ..what_rustc_thinks });
129129
Some(ret)
130130
}
131131

src/librustdoc/clean/types.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@ impl Item {
113113
self.attrs.doc_value()
114114
}
115115

116-
/// Convenience wrapper around [`Self::from_inner`] which converts `hir_id` to a [`DefId`]
116+
/// Convenience wrapper around [`Self::from_def_id_and_parts`] which converts
117+
/// `hir_id` to a [`DefId`]
117118
pub fn from_hir_id_and_parts(
118119
hir_id: hir::HirId,
119120
name: Option<Symbol>,
@@ -130,18 +131,15 @@ impl Item {
130131
cx: &DocContext<'_>,
131132
) -> Item {
132133
use super::Clean;
133-
use hir::Node;
134134

135135
debug!("name={:?}, def_id={:?}", name, def_id);
136136

137137
// `span_if_local()` lies about functions and only gives the span of the function signature
138-
let source = cx.tcx.hir().get_if_local(def_id).map_or_else(
138+
let source = def_id.as_local().map_or_else(
139139
|| cx.tcx.def_span(def_id),
140-
|node| match node {
141-
Node::Item(item) => item.span,
142-
Node::ImplItem(item) => item.span,
143-
Node::TraitItem(item) => item.span,
144-
_ => cx.tcx.hir().span_if_local(def_id).unwrap(),
140+
|local| {
141+
let hir = cx.tcx.hir();
142+
hir.span_with_body(hir.local_def_id_to_hir_id(local))
145143
},
146144
);
147145

0 commit comments

Comments
 (0)