Do not discard ?Sized
type params and suggest their removal
This commit is contained in:
parent
5fb3394cbd
commit
15a40c7ee8
32 changed files with 615 additions and 19 deletions
|
@ -128,6 +128,7 @@ impl Clean<GenericBound> for hir::GenericBound<'_> {
|
|||
fn clean(&self, cx: &mut DocContext<'_>) -> GenericBound {
|
||||
match *self {
|
||||
hir::GenericBound::Outlives(lt) => GenericBound::Outlives(lt.clean(cx)),
|
||||
hir::GenericBound::Unsized(_) => GenericBound::maybe_sized(cx),
|
||||
hir::GenericBound::LangItemTrait(lang_item, span, _, generic_args) => {
|
||||
let def_id = cx.tcx.require_lang_item(lang_item, Some(span));
|
||||
|
||||
|
@ -562,13 +563,19 @@ impl Clean<Generics> for hir::Generics<'_> {
|
|||
WherePredicate::BoundPredicate {
|
||||
ty: Generic(ref name), ref mut bounds, ..
|
||||
} => {
|
||||
if bounds.is_empty() {
|
||||
if let [] | [GenericBound::TraitBound(_, hir::TraitBoundModifier::Maybe)] =
|
||||
&bounds[..]
|
||||
{
|
||||
for param in &mut generics.params {
|
||||
match param.kind {
|
||||
GenericParamDefKind::Lifetime => {}
|
||||
GenericParamDefKind::Type { bounds: ref mut ty_bounds, .. } => {
|
||||
if ¶m.name == name {
|
||||
mem::swap(bounds, ty_bounds);
|
||||
// We now keep track of `?Sized` obligations in the HIR.
|
||||
// If we don't clear `ty_bounds` we end up with
|
||||
// `fn foo<X: ?Sized>(_: X) where X: ?Sized`.
|
||||
ty_bounds.clear();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue