Skip to content

Commit 36a7fe1

Browse files
committed
Rust: Fallback crate resolution
1 parent 4be995d commit 36a7fe1

File tree

5 files changed

+172
-80
lines changed

5 files changed

+172
-80
lines changed

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

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -28,26 +28,15 @@ module Impl {
2828
/** Gets the position of this type parameter. */
2929
int getPosition() { this = any(GenericParamList l).getTypeParam(result) }
3030

31-
private TypeBound getTypeBoundAt(int i, int j) {
32-
exists(TypeBoundList tbl | result = tbl.getBound(j) |
33-
tbl = this.getTypeBoundList() and i = 0
34-
or
35-
exists(WherePred wp |
36-
wp = this.(TypeParamItemNode).getAWherePred() and
37-
tbl = wp.getTypeBoundList() and
38-
wp = any(WhereClause wc).getPredicate(i)
39-
)
40-
)
41-
}
42-
4331
/**
4432
* Gets the `index`th type bound of this type parameter, if any.
4533
*
4634
* This includes type bounds directly on this type parameter and bounds from
4735
* any `where` clauses for this type parameter.
4836
*/
4937
TypeBound getTypeBound(int index) {
50-
result = rank[index + 1](int i, int j | | this.getTypeBoundAt(i, j) order by i, j)
38+
result =
39+
rank[index + 1](int i, int j | | this.(TypeParamItemNode).getTypeBoundAt(i, j) order by i, j)
5140
}
5241

5342
/**
@@ -56,12 +45,7 @@ module Impl {
5645
* This includes type bounds directly on this type parameter and bounds from
5746
* any `where` clauses for this type parameter.
5847
*/
59-
TypeBound getATypeBound() {
60-
// NOTE: This predicate is used in path resolution, so it can not be
61-
// defined using `getTypeBound` as that would cause non-monotonic
62-
// recursion due to the `rank`.
63-
result = this.getTypeBoundAt(_, _)
64-
}
48+
TypeBound getATypeBound() { result = this.getTypeBound(_) }
6549

6650
override string toAbbreviatedString() { result = this.getName().getText() }
6751

0 commit comments

Comments
 (0)