Skip to content

Commit 41602d3

Browse files
committed
Address review comments
1 parent c2ba4ba commit 41602d3

File tree

6 files changed

+199
-205
lines changed

6 files changed

+199
-205
lines changed

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

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -627,25 +627,30 @@ final class ImplTraitTypeReprAbstraction extends TypeAbstraction, ImplTraitTypeR
627627
}
628628

629629
/**
630-
* Holds if `root` is a valid complex [`self` root type][1], with type
631-
* parameter `tp`.
630+
* Holds if `t` is a valid complex [`self` root type][1].
632631
*
633632
* [1]: https://doc.rust-lang.org/stable/reference/items/associated-items.html#r-items.associated.fn.method.self-ty
634633
*/
635634
pragma[nomagic]
636-
predicate complexSelfRoot(Type root, TypeParameter tp) {
637-
tp = root.(RefType).getPositionalTypeParameter(_)
635+
predicate validSelfType(Type t) {
636+
t instanceof RefType
638637
or
639-
exists(Struct s |
640-
root = TStruct(s) and
641-
tp = root.getPositionalTypeParameter(0)
642-
|
643-
s instanceof BoxStruct
644-
or
645-
s instanceof RcStruct
646-
or
647-
s instanceof ArcStruct
648-
or
638+
exists(Struct s | t = TStruct(s) |
639+
s instanceof BoxStruct or
640+
s instanceof RcStruct or
641+
s instanceof ArcStruct or
649642
s instanceof PinStruct
650643
)
651644
}
645+
646+
/**
647+
* Holds if `root` is a valid complex [`self` root type][1], with type
648+
* parameter `tp`.
649+
*
650+
* [1]: https://doc.rust-lang.org/stable/reference/items/associated-items.html#r-items.associated.fn.method.self-ty
651+
*/
652+
pragma[nomagic]
653+
predicate complexSelfRoot(Type root, TypeParameter tp) {
654+
validSelfType(root) and
655+
tp = root.getPositionalTypeParameter(0)
656+
}

0 commit comments

Comments
 (0)