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 {
154
154
result .( AssocItemNode ) .hasImplementation ( ) and
155
155
not impl .declares ( name )
156
156
)
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
+ )
157
164
}
158
165
159
166
/** Gets a successor named `name` of this item, if any. */
@@ -375,6 +382,13 @@ private class BlockExprItemNode extends ItemNode instanceof BlockExpr {
375
382
}
376
383
377
384
private 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
+
378
392
override string getName ( ) { result = TypeParam .super .getName ( ) .getText ( ) }
379
393
380
394
override Namespace getNamespace ( ) { result .isType ( ) }
Original file line number Diff line number Diff line change @@ -461,7 +461,7 @@ mod m17 {
461
461
MyTrait // $ item=I2
462
462
> ( x : T ) { // $ item=I5
463
463
x. f ( ) ; // $ MISSING: item=I1
464
- T :: f ( & x) ; // $ MISSING: item=I1
464
+ T :: f ( & x) ; // $ item=I1
465
465
MyTrait :: f ( & x) ; // $ item=I1
466
466
} // I6
467
467
Original file line number Diff line number Diff line change @@ -197,6 +197,7 @@ resolvePath
197
197
| main.rs:461:7:461:13 | MyTrait | main.rs:445:5:447:5 | trait MyTrait |
198
198
| main.rs:462:10:462:10 | T | main.rs:460:10:460:10 | T |
199
199
| 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 |
200
201
| main.rs:465:9:465:15 | MyTrait | main.rs:445:5:447:5 | trait MyTrait |
201
202
| main.rs:465:9:465:18 | ...::f | main.rs:446:9:446:20 | fn f |
202
203
| 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