@@ -1661,16 +1661,23 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
1661
1661
. predicates
1662
1662
. iter ( )
1663
1663
. filter_map ( |predicate| {
1664
- let trait_ref = if let Some ( tr) = predicate. to_opt_poly_trait_ref ( ) {
1665
- tr
1666
- } else if let Some ( pred) = predicate. to_opt_type_outlives ( ) {
1667
- // these should turn up at the end
1668
- if let Some ( r) = pred. skip_binder ( ) . 1 . clean ( cx) {
1669
- regions. push ( GenericBound :: Outlives ( r) ) ;
1664
+ // Note: The substs of opaque types can contain unbound variables,
1665
+ // meaning that we have to use `ignore_qualifiers_with_unbound_vars` here.
1666
+ let trait_ref = match predicate
1667
+ . ignore_qualifiers_with_unbound_vars ( cx. tcx )
1668
+ . skip_binder ( )
1669
+ . kind ( )
1670
+ {
1671
+ ty:: PredicateKind :: Trait ( tr, _constness) => {
1672
+ ty:: Binder :: bind ( tr. trait_ref )
1673
+ }
1674
+ ty:: PredicateKind :: TypeOutlives ( pred) => {
1675
+ if let Some ( r) = pred. 1 . clean ( cx) {
1676
+ regions. push ( GenericBound :: Outlives ( r) ) ;
1677
+ }
1678
+ return None ;
1670
1679
}
1671
- return None ;
1672
- } else {
1673
- return None ;
1680
+ _ => return None ,
1674
1681
} ;
1675
1682
1676
1683
if let Some ( sized) = cx. tcx . lang_items ( ) . sized_trait ( ) {
@@ -1684,10 +1691,11 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
1684
1691
. predicates
1685
1692
. iter ( )
1686
1693
. filter_map ( |pred| {
1687
- if let ty:: PredicateKind :: Projection ( proj) =
1688
- pred. ignore_qualifiers ( ) . skip_binder ( ) . kind ( )
1694
+ if let ty:: PredicateKind :: Projection ( proj) = pred
1695
+ . ignore_qualifiers_with_unbound_vars ( cx. tcx )
1696
+ . skip_binder ( )
1697
+ . kind ( )
1689
1698
{
1690
- let proj = proj;
1691
1699
if proj. projection_ty . trait_ref ( cx. tcx )
1692
1700
== trait_ref. skip_binder ( )
1693
1701
{
0 commit comments