8000 Rust: Type inference for operator overloading by paldepind · Pull Request #19593 · github/codeql · GitHub
[go: up one dir, main page]

Skip to content

Rust: Type inference for operator overloading #19593

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 4 commits into from
May 29, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Rust: Fixes based on PR review
  • Loading branch information
paldepind committed May 28, 2025
commit 6500ebf631b85d61e948b6f77bde4611d3664e4f
8000
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ module Impl {
*
* This is either 1 for prefix operations, or 2 for binary operations.
*/
final int getNumberOfOperands() { result = count(this.getAnOperand()) }
final int getNumberOfOperands() { result = strictcount(this.getAnOperand()) }

/** Gets an operand of this operation. */
Expr getAnOperand() { result = this.getOperand(_) }
Expand Down
2 changes: 2 additions & 0 deletions rust/ql/lib/codeql/rust/internal/TypeInference.qll
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,8 @@ private module CallExprBaseMatchingInput implements MatchingInputSig {
}

private class OperationAccess extends Access instanceof Operation {
Copy link
Contributor

Choose a reason for hiding this comment

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

Add charpred with super.isOverloaded(_, _)?

OperationAccess() { super.isOverloaded(_, _) }

override Type getTypeArgument(TypeArgumentPosition apos, TypePath path) {
// The syntax for operators does not allow type arguments.
none()
Expand Down
0