Skip to content

Conversation

@hvitved
Copy link
Contributor

@hvitved hvitved commented Nov 3, 2025

Previously, we assumed that use trees { ... } always had a qualifier, but this need not be the case.

DCA looks good; we gain an additional 0.4 %-point call edges, although at the cost of a slowdown on rust (which happens because we compute more data flow, for example the predicate AccessAfterLifetime::AccessAfterLifetimeFlow::Flow::Stage3::fwdFlowThrough grows from 3,626,391,847 tuples to 4,361,916,386 tuples.).

@github-actions github-actions bot added the Rust Pull requests that update Rust code label Nov 3, 2025
@hvitved hvitved added the no-change-note-required This PR does not need a change note label Nov 3, 2025
@hvitved hvitved force-pushed the rust/path-resolution-unqualified-use-tree branch from 168b66d to 0bfc7cf Compare November 3, 2025 18:47
@hvitved hvitved force-pushed the rust/path-resolution-unqualified-use-tree branch from 0bfc7cf to 50552da Compare November 4, 2025 12:57
@hvitved hvitved marked this pull request as ready for review November 4, 2025 17:23
@hvitved hvitved requested a review from a team as a code owner November 4, 2025 17:23
Copilot AI review requested due to automatic review settings November 4, 2025 17:23
Copy link
Contributor

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 enhances path resolution for Rust use statements to support complex nested use tree patterns. Specifically, it handles cases like use {{{my::{{self as my_alias, *}}}}} where braces are deeply nested without intervening path segments.

  • Introduces getAUseTreeUseTree() to recursively traverse nested use trees that lack path segments
  • Updates path resolution logic to handle nested glob imports and aliases within brace groups
  • Adds test coverage for the new nested use tree pattern with my_alias::nested_f()

Reviewed Changes

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

File Description
rust/ql/lib/codeql/rust/internal/PathResolution.qll Core implementation adding getAUseTreeUseTree() and getAUseUseTree() helpers, and updating resolution logic to handle nested use trees without paths
rust/ql/test/library-tests/path-resolution/main.rs Test case demonstrating nested braces with alias (use {{{my::{{self as my_alias, *}}}}}) and its usage
rust/ql/test/library-tests/path-resolution/path-resolution.expected Updated expected output with new path resolutions and shifted line numbers
rust/ql/test/library-tests/path-resolution/CONSISTENCY/PathResolutionConsistency.expected Updated line numbers for consistency checks

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@hvitved hvitved requested a review from paldepind November 5, 2025 09:41
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