hack-fix to rustdoc

This commit is contained in:
Ariel Ben-Yehuda 2018-12-15 17:35:55 +02:00
parent c2aa7485d2
commit 64857de2bd

View File

@ -2643,13 +2643,24 @@ fn clean(&self, cx: &DocContext) -> Type {
}
}
ty::Dynamic(ref obj, ref reg) => {
let principal = obj.principal();
let did = principal.def_id();
// HACK: pick the first `did` as the `did` of the trait object. Someone
// might want to implement "native" support for marker-trait-only
// trait objects.
let mut dids = obj.principal_def_id().into_iter().chain(obj.auto_traits());
let did = dids.next().unwrap_or_else(|| {
panic!("found trait object `{:?}` with no traits?", self)
});
let substs = match obj.principal() {
Some(principal) => principal.skip_binder().substs,
// marker traits have no substs.
_ => cx.tcx.intern_substs(&[])
};
inline::record_extern_fqn(cx, did, TypeKind::Trait);
let mut typarams = vec![];
reg.clean(cx).map(|b| typarams.push(GenericBound::Outlives(b)));
for did in obj.auto_traits() {
for did in dids {
let empty = cx.tcx.intern_substs(&[]);
let path = external_path(cx, &cx.tcx.item_name(did).as_str(),
Some(did), false, vec![], empty);
@ -2675,7 +2686,7 @@ fn clean(&self, cx: &DocContext) -> Type {
}
let path = external_path(cx, &cx.tcx.item_name(did).as_str(), Some(did),
false, bindings, principal.skip_binder().substs);
false, bindings, substs);
ResolvedPath {
path,
typarams: Some(typarams),