@@ -1652,27 +1652,28 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
1652
1652
if binding. gen_args . parenthesized == hir:: GenericArgsParentheses :: ReturnTypeNotation {
1653
1653
let bound_vars = if let Some ( type_def_id) = type_def_id
1654
1654
&& self . tcx . def_kind ( type_def_id) == DefKind :: Trait
1655
- // FIXME(return_type_notation): We could bound supertrait methods.
1656
- && let Some ( assoc_fn) = self
1657
- . tcx
1658
- . associated_items ( type_def_id)
1659
- . find_by_name_and_kind ( self . tcx , binding. ident , ty:: AssocKind :: Fn , type_def_id)
1655
+ && let Some ( ( mut bound_vars, assoc_fn) ) =
1656
+ BoundVarContext :: supertrait_hrtb_vars (
1657
+ self . tcx ,
1658
+ type_def_id,
1659
+ binding. ident ,
1660
+ ty:: AssocKind :: Fn ,
1661
+ )
1660
1662
{
1661
- self . tcx
1662
- . generics_of ( assoc_fn. def_id )
1663
- . params
1664
- . iter ( )
1665
- . map ( |param| match param. kind {
1663
+ bound_vars. extend ( self . tcx . generics_of ( assoc_fn. def_id ) . params . iter ( ) . map (
1664
+ |param| match param. kind {
1666
1665
ty:: GenericParamDefKind :: Lifetime => ty:: BoundVariableKind :: Region (
1667
1666
ty:: BoundRegionKind :: BrNamed ( param. def_id , param. name ) ,
1668
1667
) ,
1669
1668
ty:: GenericParamDefKind :: Type { .. } => ty:: BoundVariableKind :: Ty (
1670
1669
ty:: BoundTyKind :: Param ( param. def_id , param. name ) ,
1671
1670
) ,
1672
1671
ty:: GenericParamDefKind :: Const { .. } => ty:: BoundVariableKind :: Const ,
1673
- } )
1674
- . chain ( self . tcx . fn_sig ( assoc_fn. def_id ) . subst_identity ( ) . bound_vars ( ) )
1675
- . collect ( )
1672
+ } ,
1673
+ ) ) ;
1674
+ bound_vars
1675
+ . extend ( self . tcx . fn_sig ( assoc_fn. def_id ) . subst_identity ( ) . bound_vars ( ) ) ;
1676
+ bound_vars
1676
1677
} else {
1677
1678
self . tcx . sess . delay_span_bug (
1678
1679
binding. ident . span ,
@@ -1689,8 +1690,13 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
1689
1690
} ) ;
1690
1691
} ) ;
1691
1692
} else if let Some ( type_def_id) = type_def_id {
1692
- let bound_vars =
1693
- BoundVarContext :: supertrait_hrtb_vars ( self . tcx , type_def_id, binding. ident ) ;
1693
+ let bound_vars = BoundVarContext :: supertrait_hrtb_vars (
1694
+ self . tcx ,
1695
+ type_def_id,
1696
+ binding. ident ,
1697
+ ty:: AssocKind :: Type ,
1698
+ )
1699
+ . map ( |( bound_vars, _) | bound_vars) ;
1694
1700
self . with ( scope, |this| {
1695
1701
let scope = Scope :: Supertrait {
1696
1702
bound_vars : bound_vars. unwrap_or_default ( ) ,
@@ -1720,11 +1726,15 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
1720
1726
tcx : TyCtxt < ' tcx > ,
1721
1727
def_id : DefId ,
1722
1728
assoc_name : Ident ,
1723
- ) -> Option < Vec < ty:: BoundVariableKind > > {
1729
+ assoc_kind : ty:: AssocKind ,
1730
+ ) -> Option < ( Vec < ty:: BoundVariableKind > , & ' tcx ty:: AssocItem ) > {
1724
1731
let trait_defines_associated_type_named = |trait_def_id : DefId | {
1725
- tcx. associated_items ( trait_def_id)
1726
- . find_by_name_and_kind ( tcx, assoc_name, ty:: AssocKind :: Type , trait_def_id)
1727
- . is_some ( )
1732
+ tcx. associated_items ( trait_def_id) . find_by_name_and_kind (
1733
+ tcx,
1734
+ assoc_name,
1735
+ assoc_kind,
1736
+ trait_def_id,
1737
+ )
1728
1738
} ;
1729
1739
1730
1740
use smallvec:: { smallvec, SmallVec } ;
@@ -1742,8 +1752,8 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
1742
1752
_ => break None ,
1743
1753
}
1744
1754
1745
- if trait_defines_associated_type_named ( def_id) {
1746
- break Some ( bound_vars. into_iter ( ) . collect ( ) ) ;
1755
+ if let Some ( assoc_item ) = trait_defines_associated_type_named ( def_id) {
1756
+ break Some ( ( bound_vars. into_iter ( ) . collect ( ) , assoc_item ) ) ;
1747
1757
}
1748
1758
let predicates = tcx. super_predicates_that_define_assoc_type ( ( def_id, assoc_name) ) ;
1749
1759
let obligations = predicates. predicates . iter ( ) . filter_map ( |& ( pred, _) | {
0 commit comments