File tree Expand file tree Collapse file tree 3 files changed +16
-1
lines changed
lib/codeql/rust/elements/internal
test/library-tests/path-resolution Expand file tree Collapse file tree 3 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -154,6 +154,13 @@ abstract class ItemNode extends AstNode {
154154 result .( AssocItemNode ) .hasImplementation ( ) and
155155 not impl .declares ( name )
156156 )
157+ or
158+ // type parameters have access to the associated items of its bounds
159+ this =
160+ any ( TypeParamItemNode param |
161+ result = param .resolveABound ( ) .getASuccessorRec ( name ) and
162+ result instanceof AssocItemNode
163+ )
157164 }
158165
159166 /** Gets a successor named `name` of this item, if any. */
@@ -375,6 +382,13 @@ private class BlockExprItemNode extends ItemNode instanceof BlockExpr {
375382}
376383
377384private class TypeParamItemNode extends ItemNode instanceof TypeParam {
385+ pragma [ nomagic]
386+ Path getABoundPath ( ) {
387+ result = super .getTypeBoundList ( ) .getABound ( ) .getTypeRepr ( ) .( PathTypeRepr ) .getPath ( )
388+ }
389+
390+ ItemNode resolveABound ( ) { result = resolvePath ( this .getABoundPath ( ) ) }
391+
378392 override string getName ( ) { result = TypeParam .super .getName ( ) .getText ( ) }
379393
380394 override Namespace getNamespace ( ) { result .isType ( ) }
Original file line number Diff line number Diff line change @@ -461,7 +461,7 @@ mod m17 {
461461 MyTrait // $ item=I2
462462 > ( x : T ) { // $ item=I5
463463 x. f ( ) ; // $ MISSING: item=I1
464- T :: f ( & x) ; // $ MISSING: item=I1
464+ T :: f ( & x) ; // $ item=I1
465465 MyTrait :: f ( & x) ; // $ item=I1
466466 } // I6
467467
Original file line number Diff line number Diff line change @@ -197,6 +197,7 @@ resolvePath
197197| main.rs:461:7:461:13 | MyTrait | main.rs:445:5:447:5 | trait MyTrait |
198198| main.rs:462:10:462:10 | T | main.rs:460:10:460:10 | T |
199199| main.rs:464:9:464:9 | T | main.rs:460:10:460:10 | T |
200+ | main.rs:464:9:464:12 | ...::f | main.rs:446:9:446:20 | fn f |
200201| main.rs:465:9:465:15 | MyTrait | main.rs:445:5:447:5 | trait MyTrait |
201202| main.rs:465:9:465:18 | ...::f | main.rs:446:9:446:20 | fn f |
202203| main.rs:470:9:470:9 | g | main.rs:459:5:466:5 | fn g |
You can’t perform that action at this time.
0 commit comments