Skip to content

Conversation

hvitved
Copy link
Contributor

@hvitved hvitved commented Sep 19, 2025

Follows up on #20453 and makes the visibility check for qualified path resolution more precise.

Commit-by-commit review is encouraged.

DCA looks good; 0.585 % point increase in resolvable calls.

@github-actions github-actions bot added the Rust Pull requests that update Rust code label Sep 19, 2025
@hvitved hvitved force-pushed the rust/path-resolution-use-visibility branch 2 times, most recently from 9f931be to e3b3e7c Compare September 20, 2025 12:56
@hvitved hvitved added the no-change-note-required This PR does not need a change note label Sep 21, 2025
@hvitved hvitved force-pushed the rust/path-resolution-use-visibility branch 2 times, most recently from 205c3a2 to bfcda3b Compare September 22, 2025 07:15
```
Evaluated relational algebra for predicate _PathResolution::CrateItemNode.getName/0#dispred#91b4dd6b_PathResolution::SourceFileItemNode#bd8f490__#antijoin_rhs@e84aee8k with tuple counts:
        35406180  ~0%    {3} r1 = JOIN PathResolution::SourceFileItemNode#bd8f4905 WITH `PathResolution::CrateItemNode.getName/0#dispred#91b4dd6b` CARTESIAN PRODUCT OUTPUT Lhs.0, Rhs.1, Rhs.0
            8455  ~2%    {4}    | JOIN WITH `PathResolution::declaresDirectly/3#7d0350fb_021#join_rhs` ON FIRST 2 OUTPUT Rhs.2, Lhs.0, Lhs.2, Lhs.1
            3259  ~0%    {3}    | JOIN WITH num#PathResolution::TTypeNamespace#4897e416 ON FIRST 1 OUTPUT Lhs.1, Lhs.2, Lhs.3
                         return r1
```
@hvitved hvitved force-pushed the rust/path-resolution-use-visibility branch from bfcda3b to 76ca5f8 Compare September 22, 2025 07:42
@hvitved hvitved force-pushed the rust/path-resolution-use-visibility branch from 76ca5f8 to 78641b4 Compare September 22, 2025 07:55
@hvitved hvitved marked this pull request as ready for review September 22, 2025 11:24
@hvitved hvitved requested a review from a team as a code owner September 22, 2025 11:24
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

This PR improves the visibility checking for qualified path resolution in Rust code analysis by making the visibility checks more precise. The main purpose is to refactor path resolution to better track which items are visible based on their declaration scope and any use statements that bring them into scope.

Key changes:

  • Added tracking of use statements that bring items into scope through a new UseOption type
  • Updated visibility checking to consider whether items or the use statements that import them are in ancestor modules
  • Modified various path resolution predicates to pass through and check visibility information more accurately

Reviewed Changes

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

Show a summary per file
File Description
rust/ql/lib/codeql/rust/internal/PathResolution.qll Core implementation of the visibility checking improvements with new UseOption type and updated resolution predicates
rust/ql/lib/codeql/rust/internal/CachedStages.qll Updated cached stage predicate to match the new getASuccessor signature
rust/ql/lib/utils/test/PathResolutionInlineExpectationsTest.qll Enhanced test utility to handle SourceFile items differently in expectations
rust/ql/test/library-tests/path-resolution/my2/mod.rs Added test case with std::ops::Deref import
rust/ql/test/library-tests/path-resolution/my2/my3/mod.rs Added test cases for glob imports and trait bounds
rust/ql/test/library-tests/path-resolution/path-resolution.expected Updated test expectations to reflect the improved path resolution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-change-note-required This PR does not need a change note Rust Pull requests that update Rust code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant