@@ -1664,12 +1664,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1664
1664
ObligationCauseCode :: ImplDerivedObligation ( code) => {
1665
1665
code. derived . parent_trait_pred . self_ty ( ) . skip_binder ( ) . into ( )
1666
1666
}
1667
- _ if let ty:: PredicateKind :: Trait ( predicate) =
1668
- error. obligation . predicate . kind ( ) . skip_binder ( ) =>
1669
- {
1670
- predicate. self_ty ( ) . into ( )
1671
- }
1672
- _ => continue ,
1667
+ _ => match error. obligation . predicate . kind ( ) . skip_binder ( ) {
1668
+ ty:: PredicateKind :: Trait ( predicate) => predicate. self_ty ( ) . into ( ) ,
1669
+ ty:: PredicateKind :: Projection ( predicate) => {
1670
+ predicate. projection_ty . self_ty ( ) . into ( )
1671
+ }
1672
+ _ => continue ,
1673
+ } ,
1673
1674
} ;
1674
1675
let self_ = self . resolve_vars_if_possible ( self_) ;
1675
1676
let ty_matches_self = |ty : Ty < ' tcx > | ty. walk ( ) . any ( |arg| arg == self_) ;
@@ -1759,25 +1760,28 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1759
1760
if let hir:: ExprKind :: Call ( path, _) = & call_expr. kind {
1760
1761
if let hir:: ExprKind :: Path ( hir:: QPath :: Resolved ( _, path) ) = & path. kind {
1761
1762
for error in errors {
1762
- if let ty:: PredicateKind :: Trait ( predicate) =
1763
- error. obligation . predicate . kind ( ) . skip_binder ( )
1763
+ let self_ty = match error. obligation . predicate . kind ( ) . skip_binder ( ) {
1764
+ ty:: PredicateKind :: Trait ( predicate) => predicate. self_ty ( ) ,
1765
+ ty:: PredicateKind :: Projection ( predicate) => {
1766
+ predicate. projection_ty . self_ty ( )
1767
+ }
1768
+ _ => continue ,
1769
+ } ;
1770
+ // If any of the type arguments in this path segment caused the
1771
+ // `FulfillmentError`, point at its span (#61860).
1772
+ for arg in path
1773
+ . segments
1774
+ . iter ( )
1775
+ . filter_map ( |seg| seg. args . as_ref ( ) )
1776
+ . flat_map ( |a| a. args . iter ( ) )
1764
1777
{
1765
- // If any of the type arguments in this path segment caused the
1766
- // `FulfillmentError`, point at its span (#61860).
1767
- for arg in path
1768
- . segments
1769
- . iter ( )
1770
- . filter_map ( |seg| seg. args . as_ref ( ) )
1771
- . flat_map ( |a| a. args . iter ( ) )
1778
+ if let hir:: GenericArg :: Type ( hir_ty) = & arg
1779
+ && let Some ( ty) =
1780
+ self . typeck_results . borrow ( ) . node_type_opt ( hir_ty. hir_id )
1781
+ && self . resolve_vars_if_possible ( ty) == self_ty
1772
1782
{
1773
- if let hir:: GenericArg :: Type ( hir_ty) = & arg
1774
- && let Some ( ty) =
1775
- self . typeck_results . borrow ( ) . node_type_opt ( hir_ty. hir_id )
1776
- && self . resolve_vars_if_possible ( ty) == predicate. self_ty ( )
1777
- {
1778
- error. obligation . cause . span = hir_ty. span ;
1779
- break ;
1780
- }
1783
+ error. obligation . cause . span = hir_ty. span ;
1784
+ break ;
1781
1785
}
1782
1786
}
1783
1787
}
0 commit comments