Skip to content

Rust: Fallback crate resolution #20225

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 3 additions & 19 deletions rust/ql/lib/codeql/rust/elements/internal/TypeParamImpl.qll
Original file line number Diff line number Diff line change
Expand Up @@ -28,26 +28,15 @@ module Impl {
/** Gets the position of this type parameter. */
int getPosition() { this = any(GenericParamList l).getTypeParam(result) }

private TypeBound getTypeBoundAt(int i, int j) {
exists(TypeBoundList tbl | result = tbl.getBound(j) |
tbl = this.getTypeBoundList() and i = 0
or
exists(WherePred wp |
wp = this.(TypeParamItemNode).getAWherePred() and
tbl = wp.getTypeBoundList() and
wp = any(WhereClause wc).getPredicate(i)
)
)
}

/**
* Gets the `index`th type bound of this type parameter, if any.
*
* This includes type bounds directly on this type parameter and bounds from
* any `where` clauses for this type parameter.
*/
TypeBound getTypeBound(int index) {
result = rank[index + 1](int i, int j | | this.getTypeBoundAt(i, j) order by i, j)
result =
rank[index + 1](int i, int j | | this.(TypeParamItemNode).getTypeBoundAt(i, j) order by i, j)
}

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

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

Expand Down
Loading