Skip to content

Commit 64857de

Browse files
committed
hack-fix to rustdoc
1 parent c2aa748 commit 64857de

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/librustdoc/clean/mod.rs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2643,13 +2643,24 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
26432643
}
26442644
}
26452645
ty::Dynamic(ref obj, ref reg) => {
2646-
let principal = obj.principal();
2647-
let did = principal.def_id();
2646+
// HACK: pick the first `did` as the `did` of the trait object. Someone
2647+
// might want to implement "native" support for marker-trait-only
2648+
// trait objects.
2649+
let mut dids = obj.principal_def_id().into_iter().chain(obj.auto_traits());
2650+
let did = dids.next().unwrap_or_else(|| {
2651+
panic!("found trait object `{:?}` with no traits?", self)
2652+
});
2653+
let substs = match obj.principal() {
2654+
Some(principal) => principal.skip_binder().substs,
2655+
// marker traits have no substs.
2656+
_ => cx.tcx.intern_substs(&[])
2657+
};
2658+
26482659
inline::record_extern_fqn(cx, did, TypeKind::Trait);
26492660

26502661
let mut typarams = vec![];
26512662
reg.clean(cx).map(|b| typarams.push(GenericBound::Outlives(b)));
2652-
for did in obj.auto_traits() {
2663+
for did in dids {
26532664
let empty = cx.tcx.intern_substs(&[]);
26542665
let path = external_path(cx, &cx.tcx.item_name(did).as_str(),
26552666
Some(did), false, vec![], empty);
@@ -2675,7 +2686,7 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
26752686
}
26762687

26772688
let path = external_path(cx, &cx.tcx.item_name(did).as_str(), Some(did),
2678-
false, bindings, principal.skip_binder().substs);
2689+
false, bindings, substs);
26792690
ResolvedPath {
26802691
path,
26812692
typarams: Some(typarams),

0 commit comments

Comments
 (0)