@@ -1513,25 +1513,31 @@ private module AssocFunctionResolution {
15131513 any ( AssocFunctionCall afc0 |
15141514 exists ( string name , int arity |
15151515 afc0 .hasNameAndArity ( name , arity , _, _) and
1516- assocFunctionTraitInfo ( name , arity , trait )
1517- |
1516+ assocFunctionTraitInfo ( name , arity , trait ) and
15181517 not afc0 .hasTrait ( )
1519- or
1520- trait = afc0 .getTrait ( )
15211518 )
15221519 )
15231520 }
15241521
15251522 private module AssocFunctionTraitIsVisible = TraitIsVisible< assocFunctionCallTraitCandidate / 2 > ;
15261523
1527- private predicate callVisibleTraitCandidate = AssocFunctionTraitIsVisible:: traitIsVisible / 2 ;
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+ }
15281531
15291532 bindingset [ afc, impl]
15301533 pragma [ inline_late]
15311534 private predicate callVisibleImplTraitCandidate ( AssocFunctionCall afc , ImplItemNode impl ) {
15321535 callVisibleTraitCandidate ( afc , impl .resolveTraitTy ( ) )
15331536 }
15341537
1538+ pragma [ nomagic]
1539+ private predicate implHasNoTrait ( Impl i ) { not i .hasTrait ( ) }
1540+
15351541 /**
15361542 * Holds if call `afc` may target function `f` in `i` with type `selfType` at
15371543 * `selfPos`.
@@ -1554,16 +1560,11 @@ private module AssocFunctionResolution {
15541560 assocFunctionInfoNonBlanketLike ( f , name , arity , selfPos , selfPosAdj , i , selfType ,
15551561 strippedTypePath , strippedType , implType , isMethod )
15561562 |
1557- i =
1558- any ( Impl impl |
1559- not impl .hasTrait ( )
1560- or
1561- callVisibleImplTraitCandidate ( afc , impl )
1562- )
1563+ implHasNoTrait ( i )
15631564 or
1564- callVisibleTraitCandidate ( afc , i )
1565+ callVisibleImplTraitCandidate ( afc , i )
15651566 or
1566- i . ( ImplItemNode ) . resolveTraitTy ( ) = afc . getTrait ( )
1567+ callVisibleTraitCandidate ( afc , i )
15671568 )
15681569 }
15691570
@@ -1587,11 +1588,8 @@ private module AssocFunctionResolution {
15871588 exists ( string name , int arity , boolean isMethod |
15881589 afc .hasNameAndArity ( name , arity , _, isMethod ) and
15891590 assocFunctionSelfInfoBlanketLike ( f , name , arity , selfPos , selfPosAdj , impl , _, self ,
1590- blanketPath , blanketTypeParam , isMethod )
1591- |
1591+ blanketPath , blanketTypeParam , isMethod ) and
15921592 callVisibleImplTraitCandidate ( afc , impl )
1593- or
1594- impl .resolveTraitTy ( ) = afc .getTrait ( )
15951593 )
15961594 }
15971595
0 commit comments