Skip to content

Rust: Remove Resolvable.resolvesAsItem #20027

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

Merged
merged 1 commit into from
Jul 11, 2025
Merged
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
1 change: 1 addition & 0 deletions rust/ql/.generated.list

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions rust/ql/.gitattributes

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 2 additions & 18 deletions rust/ql/lib/codeql/rust/elements/internal/ResolvableImpl.qll

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 12 additions & 2 deletions rust/ql/src/queries/telemetry/RustAnalyzerComparison.qll
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@

import rust

pragma[nomagic]
private predicate resolvesAsItem(Resolvable r, Item i) {
r.getResolvedPath() = i.getExtendedCanonicalPath() and
(
r.getResolvedCrateOrigin() = i.getCrateOrigin()
or
not r.hasResolvedCrateOrigin() and not i.hasCrateOrigin()
)
}

private signature module ResolvableSig {
class Source {
string toString();
Expand Down Expand Up @@ -94,7 +104,7 @@ private module PathResolution implements ResolvableSig {
private module RustAnalyzerPathResolution implements CompareSig<PathResolution> {
predicate isResolvable(PathResolution::Source s) { s.hasResolvedPath() }

Item resolve(PathResolution::Source s) { s.resolvesAsItem(result) }
Item resolve(PathResolution::Source s) { resolvesAsItem(s, result) }
}

private module QlPathResolution implements CompareSig<PathResolution> {
Expand Down Expand Up @@ -133,7 +143,7 @@ private module RustAnalyzerCallGraph implements CompareSig<CallGraph> {
CallExprBaseImpl::getCallResolvable(c).hasResolvedPath()
}

Item resolve(CallExprBase c) { CallExprBaseImpl::getCallResolvable(c).resolvesAsItem(result) }
Item resolve(CallExprBase c) { resolvesAsItem(CallExprBaseImpl::getCallResolvable(c), result) }
}

private module QlCallGraph implements CompareSig<CallGraph> {
Expand Down