@@ -2732,15 +2732,6 @@ private module NonMethodResolution {
27322732 /** Holds if this call targets a trait. */
27332733 predicate hasTrait ( ) { exists ( this .getTrait ( ) ) }
27342734
2735- pragma [ nomagic]
2736- NonMethodFunction resolveCallTargetNonBlanketCand ( ImplItemNode i ) {
2737- not this .hasTrait ( ) and
2738- result = this .getPathResolutionResolved ( ) and
2739- result = i .getASuccessor ( _) and
2740- not exists ( this .resolveCallTargetViaPathResolution ( ) )
2741- // FunctionOverloading::functionResolutionDependsOnArgument(i, result, _, _, _)
2742- }
2743-
27442735 AstNode getNodeAt ( FunctionPosition pos ) {
27452736 result = this .getSyntacticArgument ( pos .asArgumentPosition ( ) )
27462737 or
@@ -2752,7 +2743,16 @@ private module NonMethodResolution {
27522743 }
27532744
27542745 pragma [ nomagic]
2755- predicate resolveCallTargetBlanketLikeCandidate (
2746+ NonMethodFunction resolveCallTargetNonBlanketCand ( ImplItemNode i ) {
2747+ not this .hasTrait ( ) and
2748+ result = this .getPathResolutionResolved ( ) and
2749+ result = i .getASuccessor ( _) and
2750+ not exists ( this .resolveCallTargetViaPathResolution ( ) ) and
2751+ FunctionOverloading:: functionResolutionDependsOnArgument ( i , result , _, _)
2752+ }
2753+
2754+ pragma [ nomagic]
2755+ predicate resolveCallTargetBlanketLikeCand (
27562756 ImplItemNode impl , FunctionPosition pos , TypePath blanketPath , TypeParam blanketTypeParam
27572757 ) {
27582758 exists ( string name , int arity , Trait trait , AssocFunctionType t |
@@ -2761,6 +2761,10 @@ private module NonMethodResolution {
27612761 functionInfoBlanketLikeRelevantPos ( _, name , arity , impl , trait , pos , t , blanketPath ,
27622762 blanketTypeParam ) and
27632763 BlanketTraitIsVisible:: traitIsVisible ( this , trait )
2764+ |
2765+ not this .hasTrait ( )
2766+ or
2767+ trait = this .getTrait ( )
27642768 )
27652769 }
27662770
@@ -2776,8 +2780,7 @@ private module NonMethodResolution {
27762780 */
27772781 pragma [ nomagic]
27782782 predicate hasNoCompatibleNonBlanketTarget ( ) {
2779- // not this = Debug::getRelevantLocatable() and // todo
2780- this .resolveCallTargetBlanketLikeCandidate ( _, _, _, _) and
2783+ this .resolveCallTargetBlanketLikeCand ( _, _, _, _) and
27812784 not exists ( this .resolveCallTargetViaPathResolution ( ) ) and
27822785 forall ( ImplOrTraitItemNode i , Function f |
27832786 this .( NonMethodArgsAreInstantiationsOfNonBlanketInput1:: Call ) .hasTargetCand ( i , f )
@@ -2814,9 +2817,7 @@ private module NonMethodResolution {
28142817 result = this .resolveCallTargetBlanketCand ( i ) and
28152818 not FunctionOverloading:: functionResolutionDependsOnArgument ( _, result , _, _)
28162819 or
2817- NonMethodArgsAreInstantiationsOfBlanket1:: argsAreInstantiationsOf ( this , i , result )
2818- or
2819- NonMethodArgsAreInstantiationsOfBlanket2:: argsAreInstantiationsOf ( this , i , result )
2820+ NonMethodArgsAreInstantiationsOfBlanket:: argsAreInstantiationsOf ( this , i , result )
28202821 or
28212822 NonMethodArgsAreInstantiationsOfNonBlanket1:: argsAreInstantiationsOf ( this , i , result )
28222823 or
@@ -2833,7 +2834,7 @@ private module NonMethodResolution {
28332834
28342835 private newtype TCallAndBlanketPos =
28352836 MkCallAndBlanketPos ( NonMethodCall fc , FunctionPosition pos ) {
2836- fc .resolveCallTargetBlanketLikeCandidate ( _, pos , _, _)
2837+ fc .resolveCallTargetBlanketLikeCand ( _, pos , _, _)
28372838 }
28382839
28392840 /** A call tagged with a position. */
@@ -2859,7 +2860,7 @@ private module NonMethodResolution {
28592860 ) {
28602861 exists ( NonMethodCall fc , FunctionPosition pos |
28612862 fcp = MkCallAndBlanketPos ( fc , pos ) and
2862- fc .resolveCallTargetBlanketLikeCandidate ( impl , pos , blanketPath , blanketTypeParam ) and
2863+ fc .resolveCallTargetBlanketLikeCand ( impl , pos , blanketPath , blanketTypeParam ) and
28632864 // Only apply blanket implementations when no other implementations are possible;
28642865 // this is to account for codebases that use the (unstable) specialization feature
28652866 // (https://rust-lang.github.io/rfcs/1210-impl-specialization.html), as well as
@@ -2916,7 +2917,7 @@ private module NonMethodResolution {
29162917 )
29172918 }
29182919
2919- private module NonMethodArgsAreInstantiationsOfBlanketInput1 implements
2920+ private module NonMethodArgsAreInstantiationsOfBlanketInput implements
29202921 ArgsAreInstantiationsOfInputSig
29212922 {
29222923 predicate toCheck ( ImplOrTraitItemNode i , Function f , TypeParameter traitTp , FunctionPosition pos ) {
@@ -2933,30 +2934,8 @@ private module NonMethodResolution {
29332934 }
29342935 }
29352936
2936- private module NonMethodArgsAreInstantiationsOfBlanketInput2 implements
2937- ArgsAreInstantiationsOfInputSig
2938- {
2939- predicate toCheck ( ImplOrTraitItemNode i , Function f , TypeParameter traitTp , FunctionPosition pos ) {
2940- traitFunctionDependsOnPos2 ( _, _, pos , i , f , traitTp )
2941- }
2942-
2943- final class Call extends NonMethodCall {
2944- // Call() { this = Debug::getRelevantLocatable() } // todo
2945- Type getArgType ( FunctionPosition pos , TypePath path ) { result = getArgType ( this , pos , path ) }
2946-
2947- predicate hasTargetCand ( ImplOrTraitItemNode i , Function f ) {
2948- hasTraitResolvedCand ( this , i , f ) and
2949- BlanketImplementation:: isBlanketLike ( i , _, _) and
2950- ( this .hasNoCompatibleNonBlanketTarget ( ) or not i .( ImplItemNode ) .isBlanketImplementation ( ) ) // todo: removing this line makes the pred below work
2951- }
2952- }
2953- }
2954-
2955- private module NonMethodArgsAreInstantiationsOfBlanket1 =
2956- ArgsAreInstantiationsOf< NonMethodArgsAreInstantiationsOfBlanketInput1 > ;
2957-
2958- private module NonMethodArgsAreInstantiationsOfBlanket2 =
2959- ArgsAreInstantiationsOf< NonMethodArgsAreInstantiationsOfBlanketInput2 > ;
2937+ private module NonMethodArgsAreInstantiationsOfBlanket =
2938+ ArgsAreInstantiationsOf< NonMethodArgsAreInstantiationsOfBlanketInput > ;
29602939
29612940 private module NonMethodArgsAreInstantiationsOfNonBlanketInput1 implements
29622941 ArgsAreInstantiationsOfInputSig
@@ -2982,6 +2961,7 @@ private module NonMethodResolution {
29822961 // NonMethodArgsAreInstantiationsOfBlanketInput::toCheck(i, f, pos, t)
29832962 traitFunctionDependsOnPos2 ( _, _, pos , i , f , traitTp )
29842963 or
2964+ // FunctionOverloading::functionResolutionDependsOnArgument(i, f, traitTp, pos)
29852965 // match against the trait function itself
29862966 exists ( Trait trait |
29872967 i = trait and
0 commit comments