@@ -2643,13 +2643,24 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
2643
2643
}
2644
2644
}
2645
2645
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
+
2648
2659
inline:: record_extern_fqn ( cx, did, TypeKind :: Trait ) ;
2649
2660
2650
2661
let mut typarams = vec ! [ ] ;
2651
2662
reg. clean ( cx) . map ( |b| typarams. push ( GenericBound :: Outlives ( b) ) ) ;
2652
- for did in obj . auto_traits ( ) {
2663
+ for did in dids {
2653
2664
let empty = cx. tcx . intern_substs ( & [ ] ) ;
2654
2665
let path = external_path ( cx, & cx. tcx . item_name ( did) . as_str ( ) ,
2655
2666
Some ( did) , false , vec ! [ ] , empty) ;
@@ -2675,7 +2686,7 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
2675
2686
}
2676
2687
2677
2688
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) ;
2679
2690
ResolvedPath {
2680
2691
path,
2681
2692
typarams : Some ( typarams) ,
0 commit comments