-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
base: main
Are you sure you want to change the base?
Conversation
27fd756
to
d74e95f
Compare
There was a problem hiding this 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 inmain.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
) withfileImport
,PathUse
,FileUse
, andItemNode
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] |
There was a problem hiding this comment.
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.
pragma[nomagic] | |
pragma[nomagic] private |
Copilot uses AI. Check for mistakes.
@@ -3,6 +3,7 @@ | |||
* in the code viewer. | |||
*/ | |||
|
|||
private import rust |
There was a problem hiding this comment.
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.
private import rust |
Copilot uses AI. Check for mistakes.
No description provided.