Skip to content

Commit cf3fb23

Browse files
committed
Rust: Take internal IDs of a smaller class
1 parent 8acf9ce commit cf3fb23

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

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

+9-2
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,18 @@ private module Input1 implements InputSig1<Location> {
6969
apos.asMethodTypeArgumentPosition() = ppos.asTypeParam().getPosition()
7070
}
7171

72+
private import codeql.rust.elements.internal.generated.Synth
73+
74+
private class TTypeParameterAstNode = Synth::TTypeParam or Synth::TTrait;
75+
76+
/** An `AstNode` that might correspond to a `TypeParameter`. */
77+
private class TypeParameterAstNode extends AstNode, TTypeParameterAstNode { }
78+
7279
private predicate id(Raw::AstNode x, Raw::AstNode y) { x = y }
7380

7481
private predicate idOfRaw(Raw::AstNode x, int y) = equivalenceRelation(id/2)(x, y)
7582

76-
private int idOf(AstNode node) { idOfRaw(Synth::convertAstNodeToRaw(node), result) }
83+
private int idOf(TypeParameterAstNode node) { idOfRaw(Synth::convertAstNodeToRaw(node), result) }
7784

7885
int getTypeParameterId(TypeParameter tp) {
7986
tp =
@@ -83,7 +90,7 @@ private module Input1 implements InputSig1<Location> {
8390
id = 0
8491
or
8592
kind = 1 and
86-
exists(AstNode node | id = idOf(node) |
93+
exists(TypeParameterAstNode node | id = idOf(node) |
8794
node = tp0.(TypeParamTypeParameter).getTypeParam() or
8895
node = tp0.(SelfTypeParameter).getTrait()
8996
)

0 commit comments

Comments
 (0)