Rust: More path resolution improvements#19133
Merged
hvitved merged 2 commits intogithub:mainfrom Apr 1, 2025
Merged
Conversation
b6b6f7c to
73193d6
Compare
73193d6 to
605cf35
Compare
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR implements improvements to how Rust resolves module paths, focusing on better handling of nested module imports and restricting sibling module imports. Key changes include:
- Adding a new module file at rust/ql/test/library-tests/path-resolution/my/my4/my5/mod.rs.
- Updating rust/ql/test/library-tests/path-resolution/my.rs to re-export a nested module function.
- Enhancing rust/ql/test/library-tests/path-resolution/main.rs with a new module (m18) and its nested structure to test complex resolution scenarios.
Reviewed Changes
Copilot reviewed 3 out of 5 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| rust/ql/test/library-tests/path-resolution/my/my4/my5/mod.rs | Introduces a new module function f with a test annotation. |
| rust/ql/test/library-tests/path-resolution/my.rs | Adds a nested module my4 containing my5 and re-exports its function as nested_f. |
| rust/ql/test/library-tests/path-resolution/main.rs | Adds module m18 with nested modules to test resolution calls using relative paths. |
Files not reviewed (2)
- rust/ql/lib/codeql/rust/internal/PathResolution.qll: Language not supported
- rust/ql/test/library-tests/path-resolution/path-resolution.expected: Language not supported
Comments suppressed due to low confidence (3)
rust/ql/test/library-tests/path-resolution/main.rs:489
- [nitpick] The function name 'f' appears in both m18 and m19, which may lead to ambiguity when using relative paths. Consider renaming one of them to clarify which function is being referenced.
super::f(); // $ item=I102
rust/ql/test/library-tests/path-resolution/main.rs:490
- [nitpick] Using 'super::super::f()' in the context of similarly named functions might be unclear. A more distinct naming scheme could improve readability of the module resolution.
super::super::f(); // $ item=I101
rust/ql/test/library-tests/path-resolution/my/my4/my5/mod.rs:3
- [nitpick] The annotation 'I201' in the comment may be unclear to future maintainers. Consider providing additional context or a more descriptive comment to indicate its purpose.
} // I201
Tip: Copilot code review supports C#, Go, Java, JavaScript, Markdown, Python, Ruby and TypeScript, with more languages coming soon. Learn more
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements a couple of improvements to path resolution:
mod foo;imports inside nested modules.mod foo;imports to crate entry files andmod.rsfiles.