@@ -636,6 +636,8 @@ final class ImplItemNode extends ImplOrTraitItemNode instanceof Impl {
636
636
637
637
TraitItemNode resolveTraitTy ( ) { result = resolvePath ( this .getTraitPath ( ) ) }
638
638
639
+ predicate isBlanket ( ) { this .resolveSelfTy ( ) instanceof TypeParam }
640
+
639
641
override AssocItemNode getAnAssocItem ( ) { result = this .getADescendant ( ) }
640
642
641
643
override string getName ( ) { result = "(impl)" }
@@ -721,7 +723,7 @@ final class ImplItemNode extends ImplOrTraitItemNode instanceof Impl {
721
723
}
722
724
}
723
725
724
- final private class ImplTraitTypeReprItemNode extends TypeItemNode instanceof ImplTraitTypeRepr {
726
+ final class ImplTraitTypeReprItemNode extends TypeItemNode instanceof ImplTraitTypeRepr {
725
727
pragma [ nomagic]
726
728
Path getABoundPath ( ) {
727
729
result = super .getTypeBoundList ( ) .getABound ( ) .getTypeRepr ( ) .( PathTypeRepr ) .getPath ( )
@@ -1425,24 +1427,56 @@ signature predicate relevantTraitVisibleSig(Element element, Trait trait);
1425
1427
* at a given element.
1426
1428
*/
1427
1429
module 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
+ )
1433
1443
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 )
1439
1468
)
1440
1469
}
1441
1470
1442
1471
/** Holds if the trait `trait` is visible at `element`. */
1443
1472
pragma [ nomagic]
1444
1473
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
+ )
1446
1480
}
1447
1481
}
1448
1482
@@ -1740,7 +1774,7 @@ private module Debug {
1740
1774
exists ( string filepath , int startline , int startcolumn , int endline , int endcolumn |
1741
1775
result .getLocation ( ) .hasLocationInfo ( filepath , startline , startcolumn , endline , endcolumn ) and
1742
1776
filepath .matches ( "%/main.rs" ) and
1743
- startline = 52
1777
+ startline = 167
1744
1778
)
1745
1779
}
1746
1780
0 commit comments