Remove a Clean impl for a tuple (2)

This commit is contained in:
Noah Lev 2021-12-03 13:26:59 -08:00
parent 2fbdc79ae6
commit 63d434a363

View File

@ -138,36 +138,37 @@ fn clean(&self, cx: &mut DocContext<'_>) -> Path {
} }
} }
impl Clean<GenericBound> for (ty::PolyTraitRef<'_>, &[TypeBinding]) { fn clean_poly_trait_ref_with_bindings(
fn clean(&self, cx: &mut DocContext<'_>) -> GenericBound { cx: &mut DocContext<'_>,
let (poly_trait_ref, bindings) = *self; poly_trait_ref: ty::PolyTraitRef<'_>,
let poly_trait_ref = poly_trait_ref.lift_to_tcx(cx.tcx).unwrap(); bindings: &[TypeBinding],
) -> GenericBound {
let poly_trait_ref = poly_trait_ref.lift_to_tcx(cx.tcx).unwrap();
// collect any late bound regions // collect any late bound regions
let late_bound_regions: Vec<_> = cx let late_bound_regions: Vec<_> = cx
.tcx .tcx
.collect_referenced_late_bound_regions(&poly_trait_ref) .collect_referenced_late_bound_regions(&poly_trait_ref)
.into_iter() .into_iter()
.filter_map(|br| match br { .filter_map(|br| match br {
ty::BrNamed(_, name) => Some(GenericParamDef { ty::BrNamed(_, name) => Some(GenericParamDef {
name, name,
kind: GenericParamDefKind::Lifetime { outlives: vec![] }, kind: GenericParamDefKind::Lifetime { outlives: vec![] },
}), }),
_ => None, _ => None,
}) })
.collect(); .collect();
let trait_ = clean_trait_ref_with_bindings(cx, poly_trait_ref.skip_binder(), bindings); let trait_ = clean_trait_ref_with_bindings(cx, poly_trait_ref.skip_binder(), bindings);
GenericBound::TraitBound( GenericBound::TraitBound(
PolyTrait { trait_, generic_params: late_bound_regions }, PolyTrait { trait_, generic_params: late_bound_regions },
hir::TraitBoundModifier::None, hir::TraitBoundModifier::None,
) )
}
} }
impl<'tcx> Clean<GenericBound> for ty::PolyTraitRef<'tcx> { impl<'tcx> Clean<GenericBound> for ty::PolyTraitRef<'tcx> {
fn clean(&self, cx: &mut DocContext<'_>) -> GenericBound { fn clean(&self, cx: &mut DocContext<'_>) -> GenericBound {
(*self, &[][..]).clean(cx) clean_poly_trait_ref_with_bindings(cx, *self, &[])
} }
} }
@ -1513,7 +1514,7 @@ fn clean(&self, cx: &mut DocContext<'_>) -> Type {
} }
} }
let bounds: Vec<_> = bounds let bindings: Vec<_> = bounds
.iter() .iter()
.filter_map(|bound| { .filter_map(|bound| {
if let ty::PredicateKind::Projection(proj) = if let ty::PredicateKind::Projection(proj) =
@ -1541,7 +1542,7 @@ fn clean(&self, cx: &mut DocContext<'_>) -> Type {
}) })
.collect(); .collect();
Some((trait_ref, &bounds[..]).clean(cx)) Some(clean_poly_trait_ref_with_bindings(cx, trait_ref, &bindings))
}) })
.collect::<Vec<_>>(); .collect::<Vec<_>>();
bounds.extend(regions); bounds.extend(regions);