Skip to content

Commit f1ca0ec

Browse files
authored
Merge pull request #20233 from hvitved/rust/remove-tc
Rust: Remove TC from `ImplTraitTypeRepr.isInReturnPos`
2 parents fd020b5 + 1af6ddd commit f1ca0ec

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,18 @@ module Impl {
2323
* ```
2424
*/
2525
class ImplTraitTypeRepr extends Generated::ImplTraitTypeRepr {
26-
/** Gets the function for which this impl trait type occurs, if any. */
27-
Function getFunction() {
28-
this.getParentNode*() = [result.getRetType().getTypeRepr(), result.getAParam().getTypeRepr()]
26+
pragma[nomagic]
27+
private TypeRepr getFunctionTypeRepr(Function f) {
28+
this.getParentNode*() = result and
29+
result = [f.getRetType().getTypeRepr(), f.getAParam().getTypeRepr()]
2930
}
3031

32+
/** Gets the function for which this impl trait type occurs, if any. */
33+
Function getFunction() { exists(this.getFunctionTypeRepr(result)) }
34+
3135
/** Holds if this impl trait type occurs in the return type of a function. */
3236
predicate isInReturnPos() {
33-
this.getParentNode*() = this.getFunction().getRetType().getTypeRepr()
37+
exists(Function f | f.getRetType().getTypeRepr() = this.getFunctionTypeRepr(f))
3438
}
3539
}
3640
}

0 commit comments

Comments
 (0)