@@ -1521,23 +1521,14 @@ private module AssocFunctionResolution {
15211521
15221522 private module AssocFunctionTraitIsVisible = TraitIsVisible< assocFunctionCallTraitCandidate / 2 > ;
15231523
1524- pragma [ nomagic]
1525- predicate callVisibleTraitCandidate ( AssocFunctionCall afc , Trait trait ) {
1526- AssocFunctionTraitIsVisible:: traitIsVisible ( afc , trait )
1527- or
1528- // if the call has a trait qualifier then that trait must be visible
1529- trait = afc .getTrait ( )
1530- }
1524+ predicate callVisibleTraitCandidate = AssocFunctionTraitIsVisible:: traitIsVisible / 2 ;
15311525
15321526 bindingset [ afc, impl]
15331527 pragma [ inline_late]
15341528 private predicate callVisibleImplTraitCandidate ( AssocFunctionCall afc , ImplItemNode impl ) {
15351529 callVisibleTraitCandidate ( afc , impl .resolveTraitTy ( ) )
15361530 }
15371531
1538- pragma [ nomagic]
1539- private predicate implHasNoTrait ( Impl i ) { not i .hasTrait ( ) }
1540-
15411532 /**
15421533 * Holds if call `afc` may target function `f` in `i` with type `selfType` at
15431534 * `selfPos`.
@@ -1560,11 +1551,18 @@ private module AssocFunctionResolution {
15601551 assocFunctionInfoNonBlanketLike ( f , name , arity , selfPos , selfPosAdj , i , selfType ,
15611552 strippedTypePath , strippedType , implType , isMethod )
15621553 |
1563- implHasNoTrait ( i )
1554+ i .( Impl ) .isInherent ( ) and
1555+ not afc .hasTrait ( )
15641556 or
15651557 callVisibleImplTraitCandidate ( afc , i )
15661558 or
15671559 callVisibleTraitCandidate ( afc , i )
1560+ or
1561+ exists ( Trait trait | trait = afc .getTrait ( ) |
1562+ i .( ImplItemNode ) .resolveTraitTy ( ) = trait
1563+ or
1564+ i = trait
1565+ )
15681566 )
15691567 }
15701568
@@ -1588,8 +1586,11 @@ private module AssocFunctionResolution {
15881586 exists ( string name , int arity , boolean isMethod |
15891587 afc .hasNameAndArity ( name , arity , _, isMethod ) and
15901588 assocFunctionSelfInfoBlanketLike ( f , name , arity , selfPos , selfPosAdj , impl , _, self ,
1591- blanketPath , blanketTypeParam , isMethod ) and
1589+ blanketPath , blanketTypeParam , isMethod )
1590+ |
15921591 callVisibleImplTraitCandidate ( afc , impl )
1592+ or
1593+ impl .resolveTraitTy ( ) = afc .getTrait ( )
15931594 )
15941595 }
15951596
@@ -2314,7 +2315,7 @@ private module AssocFunctionResolution {
23142315 forall ( Impl i |
23152316 assocFunctionInfoNonBlanketLike ( _, name , arity , _, selfPosAdj , i , _, strippedTypePath ,
23162317 strippedType , _, _) and
2317- not i . hasTrait ( )
2318+ i . isInherent ( )
23182319 |
23192320 this .hasIncompatibleInherentTarget ( i )
23202321 )
@@ -2548,7 +2549,7 @@ private module AssocFunctionResolution {
25482549 AssocFunctionCallCand afcc , TypeAbstraction abs , AssocFunctionType constraint
25492550 ) {
25502551 ArgIsInstantiationOfSelfParamInput:: potentialInstantiationOf0 ( afcc , abs , constraint ) and
2551- abs = any ( Impl i | not i . hasTrait ( ) ) and
2552+ abs . ( Impl ) . isInherent ( ) and
25522553 // todo: comment
25532554 exists ( FunctionPosition selfPosAdj | afcc = MkAssocFunctionCallCand ( _, _, selfPosAdj , _, _) |
25542555 selfPosAdj .isTypeQualifier ( ) or selfPosAdj .asPosition ( ) = 0
0 commit comments