@@ -636,6 +636,8 @@ final class ImplItemNode extends ImplOrTraitItemNode instanceof Impl {
636636
637637 TraitItemNode resolveTraitTy ( ) { result = resolvePath ( this .getTraitPath ( ) ) }
638638
639+ predicate isBlanket ( ) { this .resolveSelfTy ( ) instanceof TypeParam }
640+
639641 override AssocItemNode getAnAssocItem ( ) { result = this .getADescendant ( ) }
640642
641643 override string getName ( ) { result = "(impl)" }
@@ -721,7 +723,7 @@ final class ImplItemNode extends ImplOrTraitItemNode instanceof Impl {
721723 }
722724}
723725
724- final private class ImplTraitTypeReprItemNode extends TypeItemNode instanceof ImplTraitTypeRepr {
726+ final class ImplTraitTypeReprItemNode extends TypeItemNode instanceof ImplTraitTypeRepr {
725727 pragma [ nomagic]
726728 Path getABoundPath ( ) {
727729 result = super .getTypeBoundList ( ) .getABound ( ) .getTypeRepr ( ) .( PathTypeRepr ) .getPath ( )
@@ -1425,24 +1427,56 @@ signature predicate relevantTraitVisibleSig(Element element, Trait trait);
14251427 * at a given element.
14261428 */
14271429module TraitIsVisible< relevantTraitVisibleSig / 2 relevantTraitVisible> {
1428- /** Holds if the trait might be looked up in `encl`. */
1429- private predicate traitLookup ( ItemNode encl , Element element , Trait trait ) {
1430- // lookup in immediately enclosing item
1431- relevantTraitVisible ( element , trait ) and
1432- encl .getADescendant ( ) = element
1430+ private newtype TNode =
1431+ TTrait ( Trait t ) { relevantTraitVisible ( _, t ) } or
1432+ TItemNode ( ItemNode i ) or
1433+ TElement ( Element e ) { relevantTraitVisible ( e , _) }
1434+
1435+ private predicate isTrait ( TNode n ) { n instanceof TTrait }
1436+
1437+ private predicate step ( TNode n1 , TNode n2 ) {
1438+ exists ( Trait t1 , ItemNode i2 |
1439+ n1 = TTrait ( t1 ) and
1440+ n2 = TItemNode ( i2 ) and
1441+ t1 = i2 .getASuccessor ( _, _)
1442+ )
14331443 or
1434- // lookup in an outer scope, but only if the trait is not declared in inner scope
1435- exists ( ItemNode mid |
1436- traitLookup ( mid , element , trait ) and
1437- not trait = mid .getASuccessor ( _, _) and
1438- encl = getOuterScope ( mid )
1444+ exists ( ItemNode i1 , ItemNode i2 |
1445+ n1 = TItemNode ( i1 ) and
1446+ n2 = TItemNode ( i2 ) and
1447+ i1 = getOuterScope ( i2 )
1448+ )
1449+ or
1450+ exists ( ItemNode i1 , Element e2 |
1451+ n1 = TItemNode ( i1 ) and
1452+ n2 = TElement ( e2 ) and
1453+ i1 .getADescendant ( ) = e2
1454+ )
1455+ }
1456+
1457+ private predicate isElement ( TNode n ) { n instanceof TElement }
1458+
1459+ private predicate traitIsVisibleTC ( TNode trait , TNode element ) =
1460+ doublyBoundedFastTC( step / 2 , isTrait / 1 , isElement / 1 ) ( trait , element )
1461+
1462+ pragma [ nomagic]
1463+ private predicate relevantTraitVisibleLift ( TNode trait , TElement element ) {
1464+ exists ( Trait t , Element e |
1465+ trait = TTrait ( t ) and
1466+ element = TElement ( e ) and
1467+ relevantTraitVisible ( e , t )
14391468 )
14401469 }
14411470
14421471 /** Holds if the trait `trait` is visible at `element`. */
14431472 pragma [ nomagic]
14441473 predicate traitIsVisible ( Element element , Trait trait ) {
1445- exists ( ItemNode encl | traitLookup ( encl , element , trait ) and trait = encl .getASuccessor ( _, _) )
1474+ exists ( TNode t , TNode e |
1475+ traitIsVisibleTC ( t , e ) and
1476+ relevantTraitVisibleLift ( t , e ) and
1477+ t = TTrait ( trait ) and
1478+ e = TElement ( element )
1479+ )
14461480 }
14471481}
14481482
@@ -1740,7 +1774,7 @@ private module Debug {
17401774 exists ( string filepath , int startline , int startcolumn , int endline , int endcolumn |
17411775 result .getLocation ( ) .hasLocationInfo ( filepath , startline , startcolumn , endline , endcolumn ) and
17421776 filepath .matches ( "%/main.rs" ) and
1743- startline = 52
1777+ startline = 167
17441778 )
17451779 }
17461780
0 commit comments