@@ -2229,20 +2229,25 @@ private module BlanketImplementation {
22292229 )
22302230 }
22312231
2232+ /**
2233+ * Holds if `impl` is a relevant blanket implementation that requires the
2234+ * trait `trait` and provides `f`, a method with name `name` and arity
2235+ * `arity`.
2236+ */
22322237 private predicate blanketImplementationMethod (
2233- Impl impl , Trait trait , string name , int arity , Function f
2238+ ImplItemNode impl , Trait trait , string name , int arity , Function f
22342239 ) {
22352240 isCanonicalBlanketImplementation ( impl ) and
22362241 blanketImplementationTraitBound ( impl , trait ) and
22372242 f .getParamList ( ) .hasSelfParam ( ) and
22382243 arity = f .getParamList ( ) .getNumberOfParams ( ) and
22392244 (
2240- f = impl .( ImplItemNode ) . getAssocItem ( name )
2245+ f = impl .getAssocItem ( name )
22412246 or
22422247 // If the the trait has a method with a default implementation, then that
22432248 // target is interesting as well.
2244- not exists ( impl .( ImplItemNode ) . getAssocItem ( name ) ) and
2245- f = impl .( ImplItemNode ) . resolveTraitTy ( ) .getAssocItem ( name )
2249+ not exists ( impl .getAssocItem ( name ) ) and
2250+ f = impl .resolveTraitTy ( ) .getAssocItem ( name )
22462251 ) and
22472252 // If the method is already available through one of the trait bounds on the
22482253 // type parameter (because they share a common trait ancestor) then ignore
@@ -2262,10 +2267,22 @@ private module BlanketImplementation {
22622267 )
22632268 }
22642269
2270+ private predicate relevantTraitVisible ( Element mc , Trait trait ) {
2271+ exists ( ImplItemNode impl |
2272+ methodCallMatchesBlanketImpl ( mc , _, impl , _, _) and
2273+ trait = impl .resolveTraitTy ( )
2274+ )
2275+ }
2276+
22652277 module SatisfiesConstraintInput implements SatisfiesConstraintInputSig< MethodCall > {
22662278 pragma [ nomagic]
22672279 predicate relevantConstraint ( MethodCall mc , Type constraint ) {
2268- methodCallMatchesBlanketImpl ( mc , _, _, constraint .( TraitType ) .getTrait ( ) , _)
2280+ exists ( Trait trait , Trait trait2 , ImplItemNode impl |
2281+ methodCallMatchesBlanketImpl ( mc , _, impl , trait , _) and
2282+ TraitIsVisible< relevantTraitVisible / 2 > :: traitIsVisible ( mc , pragma [ only_bind_into ] ( trait2 ) ) and
2283+ trait2 = pragma [ only_bind_into ] ( impl .resolveTraitTy ( ) ) and
2284+ trait = constraint .( TraitType ) .getTrait ( )
2285+ )
22692286 }
22702287
22712288 predicate useUniversalConditions ( ) { none ( ) }
0 commit comments