@@ -2215,20 +2215,25 @@ private module BlanketImplementation {
22152215 )
22162216 }
22172217
2218+ /**
2219+ * Holds if `impl` is a relevant blanket implementation that requires the
2220+ * trait `trait` and provides `f`, a method with name `name` and arity
2221+ * `arity`.
2222+ */
22182223 private predicate blanketImplementationMethod (
2219- Impl impl , Trait trait , string name , int arity , Function f
2224+ ImplItemNode impl , Trait trait , string name , int arity , Function f
22202225 ) {
22212226 isCanonicalBlanketImplementation ( impl ) and
22222227 blanketImplementationTraitBound ( impl , trait ) and
22232228 f .getParamList ( ) .hasSelfParam ( ) and
22242229 arity = f .getParamList ( ) .getNumberOfParams ( ) and
22252230 (
2226- f = impl .( ImplItemNode ) . getAssocItem ( name )
2231+ f = impl .getAssocItem ( name )
22272232 or
22282233 // If the the trait has a method with a default implementation, then that
22292234 // target is interesting as well.
2230- not exists ( impl .( ImplItemNode ) . getAssocItem ( name ) ) and
2231- f = impl .( ImplItemNode ) . resolveTraitTy ( ) .getAssocItem ( name )
2235+ not exists ( impl .getAssocItem ( name ) ) and
2236+ f = impl .resolveTraitTy ( ) .getAssocItem ( name )
22322237 ) and
22332238 // If the method is already available through one of the trait bounds on the
22342239 // type parameter (because they share a common trait ancestor) then ignore
@@ -2248,10 +2253,21 @@ private module BlanketImplementation {
22482253 )
22492254 }
22502255
2256+ private predicate relevantTraitVisible ( Element mc , Trait trait ) {
2257+ exists ( ImplItemNode impl |
2258+ methodCallMatchesBlanketImpl ( mc , _, impl , _, _) and
2259+ trait = impl .resolveTraitTy ( )
2260+ )
2261+ }
2262+
22512263 module SatisfiesConstraintInput implements SatisfiesConstraintInputSig< MethodCall > {
22522264 pragma [ nomagic]
22532265 predicate relevantConstraint ( MethodCall mc , Type constraint ) {
2254- methodCallMatchesBlanketImpl ( mc , _, _, constraint .( TraitType ) .getTrait ( ) , _)
2266+ exists ( Trait trait , Trait trait2 , ImplItemNode impl |
2267+ methodCallMatchesBlanketImpl ( mc , _, impl , trait , _) and
2268+ TraitIsVisible< relevantTraitVisible / 2 > :: traitIsVisible ( mc , impl .resolveTraitTy ( ) ) and
2269+ trait = constraint .( TraitType ) .getTrait ( )
2270+ )
22552271 }
22562272
22572273 predicate useUniversalConditions ( ) { none ( ) }
0 commit comments