Skip to content

Commit 6a547b4

Browse files
committed
rustdoc: Handle explicit ?Sized on foreign impl Trait
1 parent 32446f8 commit 6a547b4

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/librustdoc/clean/mod.rs

+14-3
Original file line numberDiff line numberDiff line change
@@ -2763,20 +2763,26 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
27632763
let predicates_of = cx.tcx.predicates_of(def_id);
27642764
let substs = cx.tcx.lift(&substs).unwrap();
27652765
let bounds = predicates_of.instantiate(cx.tcx, substs);
2766-
ImplTrait(bounds.predicates.iter().filter_map(|predicate| {
2766+
let mut regions = vec![];
2767+
let mut has_sized = false;
2768+
let mut bounds = bounds.predicates.iter().filter_map(|predicate| {
27672769
let trait_ref = if let Some(tr) = predicate.to_opt_poly_trait_ref() {
27682770
tr
2771+
} else if let ty::Predicate::TypeOutlives(pred) = *predicate {
2772+
// these should turn up at the end
2773+
pred.skip_binder().1.clean(cx).map(|r| regions.push(RegionBound(r)));
2774+
return None;
27692775
} else {
27702776
return None;
27712777
};
27722778

27732779
if let Some(sized) = cx.tcx.lang_items().sized_trait() {
27742780
if trait_ref.def_id() == sized {
2781+
has_sized = true;
27752782
return None;
27762783
}
27772784
}
27782785

2779-
// FIXME(Manishearth) handle cases which aren't Sized
27802786

27812787
let bounds = bounds.predicates.iter().filter_map(|pred|
27822788
if let ty::Predicate::Projection(proj) = *pred {
@@ -2796,7 +2802,12 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
27962802
).collect();
27972803

27982804
Some((trait_ref.skip_binder(), bounds).clean(cx))
2799-
}).collect())
2805+
}).collect::<Vec<_>>();
2806+
bounds.extend(regions);
2807+
if !has_sized && !bounds.is_empty() {
2808+
bounds.insert(0, TyParamBound::maybe_sized(cx));
2809+
}
2810+
ImplTrait(bounds)
28002811
}
28012812

28022813
ty::TyClosure(..) | ty::TyGenerator(..) => Tuple(vec![]), // FIXME(pcwalton)

0 commit comments

Comments
 (0)