Rollup merge of #110904 - fmease:rustdoc-fix-110900, r=compiler-errors

rustdoc: rebind bound vars to type-outlives predicates

Fixes #110900.
This commit is contained in:
Matthias Krüger 2023-04-28 07:34:03 +02:00 committed by GitHub
commit 8ce92daa85
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 5 deletions

View File

@ -304,7 +304,7 @@ pub(crate) fn clean_predicate<'tcx>(
clean_region_outlives_predicate(pred)
}
ty::PredicateKind::Clause(ty::Clause::TypeOutlives(pred)) => {
clean_type_outlives_predicate(pred, cx)
clean_type_outlives_predicate(bound_predicate.rebind(pred), cx)
}
ty::PredicateKind::Clause(ty::Clause::Projection(pred)) => {
Some(clean_projection_predicate(bound_predicate.rebind(pred), cx))
@ -345,7 +345,7 @@ fn clean_poly_trait_predicate<'tcx>(
}
fn clean_region_outlives_predicate<'tcx>(
pred: ty::OutlivesPredicate<ty::Region<'tcx>, ty::Region<'tcx>>,
pred: ty::RegionOutlivesPredicate<'tcx>,
) -> Option<WherePredicate> {
let ty::OutlivesPredicate(a, b) = pred;
@ -358,13 +358,13 @@ fn clean_region_outlives_predicate<'tcx>(
}
fn clean_type_outlives_predicate<'tcx>(
pred: ty::OutlivesPredicate<Ty<'tcx>, ty::Region<'tcx>>,
pred: ty::Binder<'tcx, ty::TypeOutlivesPredicate<'tcx>>,
cx: &mut DocContext<'tcx>,
) -> Option<WherePredicate> {
let ty::OutlivesPredicate(ty, lt) = pred;
let ty::OutlivesPredicate(ty, lt) = pred.skip_binder();
Some(WherePredicate::BoundPredicate {
ty: clean_middle_ty(ty::Binder::dummy(ty), cx, None),
ty: clean_middle_ty(pred.rebind(ty), cx, None),
bounds: vec![GenericBound::Outlives(
clean_middle_region(lt).expect("failed to clean lifetimes"),
)],

View File

@ -0,0 +1,28 @@
// check-pass
#![crate_type="lib"]
#![feature(associated_type_bounds)]
trait A<'a> {}
trait B<'b> {}
trait C<'c>: for<'a> A<'a> + for<'b> B<'b> {
type As;
}
trait E<'e> {
type As;
}
trait F<'f>: for<'a> A<'a> + for<'e> E<'e> {}
struct G<T>
where
T: for<'l, 'i> H<'l, 'i, As: for<'a> A<'a> + 'i>
{
t: std::marker::PhantomData<T>,
}
trait I<'a, 'b, 'c> {
type As;
}
trait H<'d, 'e>: for<'f> I<'d, 'f, 'e> + 'd {}