diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index a91f2fd7474..b32e76a6f2e 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -2416,6 +2416,14 @@ impl Clean for hir::Ty { Array(box ty.clean(cx), length) }, TyKind::Tup(ref tys) => Tuple(tys.clean(cx)), + TyKind::Def(item_id, _) => { + let item = cx.tcx.hir.expect_item(item_id.id); + if let hir::ItemKind::Existential(ref ty) = item.node { + ImplTrait(ty.bounds.clean(cx)) + } else { + unreachable!() + } + } TyKind::Path(hir::QPath::Resolved(None, ref path)) => { if let Some(new_ty) = cx.ty_substs.borrow().get(&path.def).cloned() { return new_ty; @@ -2425,14 +2433,6 @@ impl Clean for hir::Ty { if let Some(bounds) = cx.impl_trait_bounds.borrow_mut().remove(&did) { return ImplTrait(bounds); } - } else if let Def::Existential(did) = path.def { - // This block is for returned impl trait only. - if let Some(node_id) = cx.tcx.hir.as_local_node_id(did) { - let item = cx.tcx.hir.expect_item(node_id); - if let hir::ItemKind::Existential(ref ty) = item.node { - return ImplTrait(ty.bounds.clean(cx)); - } - } } let mut alias = None;