Skip to content

Rust: Extend jump-to-def to include paths and mod file; imports #19605

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

hvitved
Copy link
Contributor

@hvitved hvitved commented May 28, 2025

No description provided.

@github-actions github-actions bot added the Rust Pull requests that update Rust code label May 28, 2025
@hvitved hvitved force-pushed the rust/jump-to-def-extensions branch from 27fd756 to d74e95f Compare May 28, 2025 11:29
@hvitved hvitved marked this pull request as ready for review May 28, 2025 12:29
@Copilot Copilot AI review requested due to automatic review settings May 28, 2025 12:29
@hvitved hvitved requested a review from a team as a code owner May 28, 2025 12:29
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 support for resolving paths and file imports (mod file;) in Rust jump-to-definition.

  • Introduce a struct S, mod lib;, and reference in main.rs for new resolution tests
  • Update test query (Definitions.ql) to only select source uses and refresh expected results (Definitions.expected)
  • Extend internal QL libraries (PathResolution.qll, Definitions.qll) with fileImport, PathUse, FileUse, and ItemNode support

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
rust/ql/test/library-tests/definitions/main.rs Add struct S, mod lib;, and a let x = S usage for path resolution testing
rust/ql/test/library-tests/definitions/Definitions.ql Filter Use to fromSource() in test query
rust/ql/test/library-tests/definitions/Definitions.expected Updated expected table to include path and file entries
rust/ql/lib/codeql/rust/internal/PathResolution.qll Added pragma[nomagic] on fileImport predicate
rust/ql/lib/codeql/rust/internal/Definitions.qll Imported PathResolution, added TItemNode, extended Definition and defined PathUse & FileUse

@@ -1021,7 +1021,8 @@ private predicate pathAttrImport(Folder f, Module m, string relativePath) {
private predicate shouldAppend(Folder f, string relativePath) { pathAttrImport(f, _, relativePath) }

/** Holds if `m` is a `mod name;` item importing file `f`. */
private predicate fileImport(Module m, SourceFile f) {
pragma[nomagic]
Copy link
Preview

Copilot AI May 28, 2025

Choose a reason for hiding this comment

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

[nitpick] After marking fileImport with pragma[nomagic], consider re-adding the private qualifier (e.g. pragma[nomagic] private predicate fileImport…) to keep its visibility scope intentional.

Suggested change
pragma[nomagic]
pragma[nomagic] private

Copilot uses AI. Check for mistakes.

@@ -3,6 +3,7 @@
* in the code viewer.
*/

private import rust
Copy link
Preview

Copilot AI May 28, 2025

Choose a reason for hiding this comment

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

[nitpick] The private import rust line does not appear to be used by this module; you may remove it to avoid unnecessary imports.

Suggested change
private import rust

Copilot uses AI. Check for mistakes.

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.

1 participant