Skip to content

Conversation

@hvitved
Copy link
Contributor

@hvitved hvitved commented Jun 18, 2025

For example, use std::{self as ztd} introduces ztd as an alias for std.

@github-actions github-actions bot added the Rust Pull requests that update Rust code label Jun 18, 2025
@hvitved hvitved marked this pull request as ready for review June 19, 2025 08:19
Copilot AI review requested due to automatic review settings June 19, 2025 08:19
@hvitved hvitved requested a review from a team as a code owner June 19, 2025 08:19
@hvitved hvitved requested a review from paldepind June 19, 2025 08:19
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

Adds support for resolving paths introduced via crate::{self as foo} (e.g., use std::{self as ztd}) by updating tests and extending the QL path‐resolution logic.

  • Updated expected outputs in library‐tests to include std::{self as ztd} entries and adjust offsets.
  • Added an example import and usage of std::{self as ztd} in main.rs.
  • Extended PathResolution.qll to treat Crate nodes as valid targets when resolving self.

Reviewed Changes

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

File Description
rust/ql/test/library-tests/path-resolution/path-resolution.expected Adjusted several SourceFile offsets and inserted new lines for the ztd alias.
rust/ql/test/library-tests/path-resolution/main.rs Added use std::{self as ztd} and example usage; reformatted impl AStruct block.
rust/ql/test/library-tests/path-resolution/CONSISTENCY/PathResolutionConsistency.expected Shifted line numbers for proc_macro entries to match the updated main.rs.
rust/ql/lib/codeql/rust/internal/PathResolution.qll Expanded the self‐resolution clause to include Crate instances.
Comments suppressed due to low confidence (2)

rust/ql/test/library-tests/path-resolution/CONSISTENCY/PathResolutionConsistency.expected:6

  • Consider adding consistency tests for the new std::{self as ztd} alias to ensure the alias is resolved exactly once, similar to the existing proc_macro entries.
| main.rs:632:7:632:16 | proc_macro | file://:0:0:0:0 | Crate(proc_macro@0.0.0) |

rust/ql/lib/codeql/rust/internal/PathResolution.qll:208

  • [nitpick] The new if block for including this instanceof Crate is indented more deeply than the surrounding clauses; aligning its indentation with the other conditions would improve readability and maintain consistency.
    if

@hvitved hvitved merged commit b234d77 into github:main Jun 20, 2025
17 checks passed
@hvitved hvitved deleted the rust/path-resolution-crate-self branch June 20, 2025 12:50
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.

2 participants