Skip to content

Commit c3739d4

Browse files
committed
Address review comments
1 parent 255f06b commit c3739d4

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

rust/ql/lib/codeql/rust/elements/internal/CallExprBaseImpl.qll

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ module Impl {
2727
*/
2828
class CallExprBase extends Generated::CallExprBase {
2929
/** Gets the static target of this call, if any. */
30-
Callable getStaticTarget() { none() } // overridden by subclasses
30+
Callable getStaticTarget() { none() } // overridden by subclasses, but cannot be made abstract
3131
}
3232
}

rust/ql/lib/codeql/rust/internal/PathResolution.qll

+8-9
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,11 @@ abstract class ImplOrTraitItemNode extends ItemNode {
295295
predicate hasAssocItem(string name) { name = this.getAnAssocItem().getName() }
296296
}
297297

298+
pragma[nomagic]
299+
private TypeParamItemNode resolveTypeParamPathTypeRepr(PathTypeRepr ptr) {
300+
result = resolvePath(ptr.getPath())
301+
}
302+
298303
class ImplItemNode extends ImplOrTraitItemNode instanceof Impl {
299304
Path getSelfPath() { result = super.getSelfTy().(PathTypeRepr).getPath() }
300305

@@ -310,12 +315,6 @@ class ImplItemNode extends ImplOrTraitItemNode instanceof Impl {
310315
this.getSelfPath().getPart().getGenericArgList().getAGenericArg().(TypeArg).getTypeRepr()
311316
}
312317

313-
pragma[nomagic]
314-
private TypeParamItemNode getASelfTyTypeParamArg(TypeRepr arg) {
315-
arg = this.getASelfTyArg() and
316-
result = resolvePath(arg.(PathTypeRepr).getPath())
317-
}
318-
319318
/**
320319
* Holds if this `impl` block is not fully parametric. That is, the implementing
321320
* type is generic and the implementation is not parametrically polymorphic in all
@@ -340,9 +339,9 @@ class ImplItemNode extends ImplOrTraitItemNode instanceof Impl {
340339
pragma[nomagic]
341340
predicate isNotFullyParametric() {
342341
exists(TypeRepr arg | arg = this.getASelfTyArg() |
343-
not exists(this.getASelfTyTypeParamArg(arg))
342+
not exists(resolveTypeParamPathTypeRepr(arg))
344343
or
345-
this.getASelfTyTypeParamArg(arg).hasTraitBound()
344+
resolveTypeParamPathTypeRepr(arg).hasTraitBound()
346345
)
347346
}
348347

@@ -500,7 +499,7 @@ private class TypeParamItemNode extends ItemNode instanceof TypeParam {
500499
exists(this.getABoundPath())
501500
or
502501
exists(ItemNode declaringItem, WherePred wp |
503-
this = resolvePath(wp.getTypeRepr().(PathTypeRepr).getPath()) and
502+
this = resolveTypeParamPathTypeRepr(wp.getTypeRepr()) and
504503
wp = declaringItem.getADescendant() and
505504
this = declaringItem.getADescendant()
506505
)

0 commit comments

Comments
 (0)