Skip to content

Commit f4b4294

Browse files
committed
Remove FIXME and fix inconsistency of local blanket impls by using HIR for them
1 parent 84e9189 commit f4b4294

File tree

2 files changed

+23
-20
lines changed

2 files changed

+23
-20
lines changed

src/librustdoc/clean/blanket_impl.rs

+22-6
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,27 @@ impl<'a, 'tcx> BlanketImplFinder<'a, 'tcx> {
101101

102102
cx.generated_synthetics.insert((ty, trait_def_id));
103103

104+
let hir_imp = impl_def_id.as_local()
105+
.map(|local| cx.tcx.hir().expect_item(local))
106+
.and_then(|item| if let hir::ItemKind::Impl(i) = &item.kind {
107+
Some(i)
108+
} else {
109+
None
110+
});
111+
112+
let items = match hir_imp {
113+
Some(imp) => imp
114+
.items
115+
.iter()
116+
.map(|ii| cx.tcx.hir().impl_item(ii.id).clean(cx))
117+
.collect::<Vec<_>>(),
118+
None => cx.tcx
119+
.associated_items(impl_def_id)
120+
.in_definition_order()
121+
.map(|x| x.clean(cx))
122+
.collect::<Vec<_>>(),
123+
};
124+
104125
impls.push(Item {
105126
name: None,
106127
attrs: Default::default(),
@@ -117,12 +138,7 @@ impl<'a, 'tcx> BlanketImplFinder<'a, 'tcx> {
117138
// the post-inference `trait_ref`, as it's more accurate.
118139
trait_: Some(trait_ref.clean(cx)),
119140
for_: ty.clean(cx),
120-
items: cx
121-
.tcx
122-
.associated_items(impl_def_id)
123-
.in_definition_order()
124-
.map(|x| x.clean(cx))
125-
.collect::<Vec<_>>(),
141+
items,
126142
polarity: ty::ImplPolarity::Positive,
127143
kind: ImplKind::Blanket(box trait_ref.self_ty().clean(cx)),
128144
}),

src/librustdoc/json/mod.rs

+1-14
Original file line numberDiff line numberDiff line change
@@ -172,21 +172,8 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> {
172172
/// the hashmap because certain items (traits and types) need to have their mappings for trait
173173
/// implementations filled out before they're inserted.
174174
fn item(&mut self, item: clean::Item) -> Result<(), Error> {
175-
let local_blanket_impl = match item.def_id {
176-
clean::ItemId::Blanket { impl_id, .. } => impl_id.is_local(),
177-
clean::ItemId::Auto { .. }
178-
| clean::ItemId::DefId(_)
179-
| clean::ItemId::Primitive(_, _) => false,
180-
};
181-
182175
// Flatten items that recursively store other items
183-
// FIXME(CraftSpider): We skip children of local blanket implementations, as we'll have
184-
// already seen the actual generic impl, and the generated ones don't need documenting.
185-
// This is necessary due to the visibility, return type, and self arg of the generated
186-
// impls not quite matching, and will no longer be necessary when the mismatch is fixed.
187-
if !local_blanket_impl {
188-
item.kind.inner_items().for_each(|i| self.item(i.clone()).unwrap());
189-
}
176+
item.kind.inner_items().for_each(|i| self.item(i.clone()).unwrap());
190177

191178
let id = item.def_id;
192179
if let Some(mut new_item) = self.convert_item(item) {

0 commit comments

Comments
 (0)