Skip to content

Rust: Temporarily disable type information to flow into operands #19755

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
Jun 13, 2025

Conversation

hvitved
Copy link
Contributor

@hvitved hvitved commented Jun 13, 2025

No description provided.

@github-actions github-actions bot added the Rust Pull requests that update Rust code label Jun 13, 2025
@hvitved hvitved marked this pull request as ready for review June 13, 2025 12:50
@Copilot Copilot AI review requested due to automatic review settings June 13, 2025 12:50
@hvitved hvitved requested a review from a team as a code owner June 13, 2025 12:50
@hvitved hvitved requested a review from paldepind June 13, 2025 12:51
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR temporarily adjusts type inference to prevent implicit borrow types (&, &T) from flowing into operands by:

  • Updating expected test outputs to remove borrow-related entries.
  • Adding a conditional filter in TypeInference.qll so only return positions on operations retain their inferred types.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
rust/ql/test/library-tests/type-inference/type-inference.expected Removed lines expecting & and &T in operand types
rust/ql/lib/codeql/rust/internal/TypeInference.qll Added workaround clause to restrict borrow inference
Comments suppressed due to low confidence (2)

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

  • [nitpick] Include a TODO with a reference to the issue or feature request that will address implicit borrows properly, so this workaround is tracked and removed later.
// temporary workaround until implicit borrows are handled correctly

rust/ql/test/library-tests/type-inference/type-inference.expected:2300

  • [nitpick] Consider adding explicit tests for operations in non-return contexts to verify that borrow types are indeed suppressed, ensuring this change doesn’t regress in other scenarios.
-| main.rs:1595:13:1595:14 | v2 |  | file://:0:0:0:0 | &T |

result = CallExprBaseMatching::inferAccessType(a, apos, path0)
result = CallExprBaseMatching::inferAccessType(a, apos, path0) and
// temporary workaround until implicit borrows are handled correctly
if a instanceof Operation then apos.isReturn() else any()
Copy link
Preview

Copilot AI Jun 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] This if expression can be simplified to a boolean expression: not(a instanceof Operation) or apos.isReturn(), which is more idiomatic and easier to read.

Suggested change
if a instanceof Operation then apos.isReturn() else any()
not(a instanceof Operation) or apos.isReturn()

Copilot uses AI. Check for mistakes.

Copy link
Contributor

@paldepind paldepind left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@hvitved hvitved merged commit 6cca016 into github:main Jun 13, 2025
16 checks passed
@hvitved hvitved deleted the rust/type-inference-operand-workaround branch June 13, 2025 13:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Rust Pull requests that update Rust code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants