From: Guillaume Gomez Date: Wed, 22 Aug 2018 15:45:36 +0000 (+0200) Subject: Rollup merge of #53541 - GuillaumeGomez:fix-impl-trait-ret-type, r=oli-obk X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=3d8e760bf81019b0ab94b2112b3ef27ce0eb7259;hp=-c;p=rust.git Rollup merge of #53541 - GuillaumeGomez:fix-impl-trait-ret-type, r=oli-obk Fix missing impl trait display as ret type I need to convert a `TraitPredicate` into a `TraitBound` to get the returned impl trait. So far, didn't find how or even if it was the good way to do it. cc @eddyb @oli-obk (since you're the one behind the change apparently 😉) --- 3d8e760bf81019b0ab94b2112b3ef27ce0eb7259 diff --combined src/librustdoc/clean/mod.rs index 6cb37c0e6de,57ae2ac3a5b..a7fe15deb52 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@@ -2378,6 -2378,7 +2378,7 @@@ impl From for PrimitiveTy impl Clean for hir::Ty { fn clean(&self, cx: &DocContext) -> Type { use rustc::hir::*; + match self.node { TyKind::Never => Never, TyKind::Ptr(ref m) => RawPointer(m.mutbl.clean(cx), box m.ty.clean(cx)), @@@ -2415,6 -2416,14 +2416,14 @@@ 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; @@@ -2432,7 -2441,10 +2441,7 @@@ let mut ty_substs = FxHashMap(); let mut lt_substs = FxHashMap(); provided_params.with_generic_args(|generic_args| { - let mut indices = ty::GenericParamCount { - lifetimes: 0, - types: 0 - }; + let mut indices: GenericParamCount = Default::default(); for param in generics.params.iter() { match param.kind { hir::GenericParamKind::Lifetime { .. } => {