Skip to content

Rust: add Callable::getParam and CallExprBase::getArg shortcuts #19708

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 2 commits into from
Jun 10, 2025

Conversation

redsun82
Copy link
Contributor

No description provided.

@Copilot Copilot AI review requested due to automatic review settings June 10, 2025 07:52
@redsun82 redsun82 requested a review from a team as a code owner June 10, 2025 07:52
@github-actions github-actions bot added the Rust Pull requests that update Rust code label Jun 10, 2025
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

Adds helper shortcuts and corresponding CodeQL implementations to simplify accessing function parameters and call arguments in the Rust AST.

  • Introduces synthetic params and args fields in the schema for Callable and CallExprBase, respectively.
  • Implements getParam and getArg overrides in the CodeQL internal modules.
  • Updates imports, linguist settings, and generated file lists to wire in new extractor tests.

Reviewed Changes

Copilot reviewed 26 out of 26 changed files in this pull request and generated no comments.

Show a summary per file
File Description
rust/schema/prelude.py Add synthetic params field to Callable
rust/schema/annotations.py Add synthetic args field to CallExprBase
rust/ql/lib/codeql/rust/elements/internal/CallableImpl.qll Implement getParam(index) override
rust/ql/lib/codeql/rust/elements/internal/CallExprBaseImpl.qll Implement getArg(index) override
rust/ql/lib/codeql/rust/elements/Callable.qll Import Param to support getParam
rust/ql/.gitattributes Adjust linguist-generated entries, add new tests
rust/ql/.generated.list Update checksums and include new generated files
Comments suppressed due to low confidence (4)

rust/schema/prelude.py:76

  • [nitpick] Add a docstring entry in the class-level comment to describe the purpose of the synthetic params field.
params: list["Param"] | synth

rust/schema/annotations.py:229

  • [nitpick] Include a docstring entry explaining the synthetic args field in the CallExprBase class doc.
args: list["Expr"] | synth

rust/ql/lib/codeql/rust/elements/internal/CallableImpl.qll:19

  • [nitpick] Add a QLdoc comment above getParam describing its behavior (retrieves the parameter at the given index) and its return type.
override Param getParam(int index) { result = this.getParamList().getParam(index) }

rust/ql/lib/codeql/rust/elements/internal/CallExprBaseImpl.qll:32

  • [nitpick] Add a QLdoc comment above getArg explaining that it returns the call argument at the specified index.
override Expr getArg(int index) { result = this.getArgList().getArg(index) }

@@ -6,6 +6,7 @@
private import internal.CallableImpl
import codeql.rust.elements.AstNode
import codeql.rust.elements.Attr
import codeql.rust.elements.Param

Check warning

Code scanning / CodeQL

Redundant import Warning

Redundant import, the module is already imported inside
codeql.rust.elements.ParamList
.
@@ -8,6 +8,7 @@
private import codeql.rust.elements.internal.generated.Raw
import codeql.rust.elements.ArgList
import codeql.rust.elements.Attr
import codeql.rust.elements.Expr

Check warning

Code scanning / CodeQL

Redundant import Warning generated

Redundant import, the module is already imported inside
codeql.rust.elements.ArgList
.
@@ -8,6 +8,7 @@
private import codeql.rust.elements.internal.generated.Raw
import codeql.rust.elements.internal.AstNodeImpl::Impl as AstNodeImpl
import codeql.rust.elements.Attr
import codeql.rust.elements.Param

Check warning

Code scanning / CodeQL

Redundant import Warning generated

Redundant import, the module is already imported inside
codeql.rust.elements.ParamList
.
@redsun82
Copy link
Contributor Author

language test failure is not relevant for this PR, and is being addressed here

@redsun82 redsun82 merged commit 8f0f200 into main Jun 10, 2025
16 checks passed
@redsun82 redsun82 deleted the redsun82/rust-getArg-getParam branch June 10, 2025 13:31
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