Skip to content

Rust: Small refactor in TypeMention.qll#21422

Open
hvitved wants to merge 1 commit intogithub:mainfrom
hvitved:rust/type-mention-refactor
Open

Rust: Small refactor in TypeMention.qll#21422
hvitved wants to merge 1 commit intogithub:mainfrom
hvitved:rust/type-mention-refactor

Conversation

@hvitved
Copy link
Contributor

@hvitved hvitved commented Mar 6, 2026

#21420 follow-up; should hopefully make the check in getPathConcreteAssocTypeAt a bit more clear.

@github-actions github-actions bot added the Rust Pull requests that update Rust code label Mar 6, 2026
@hvitved hvitved added the no-change-note-required This PR does not need a change note label Mar 6, 2026
@hvitved hvitved marked this pull request as ready for review March 6, 2026 17:31
@hvitved hvitved requested a review from a team as a code owner March 6, 2026 17:31
@hvitved hvitved requested review from Copilot and paldepind March 6, 2026 17:31
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

Follow-up refactor to make the trait-specificity check in getPathConcreteAssocTypeAt clearer when resolving associated type paths in Rust type inference (per #21420).

Changes:

  • Refactors pathConcreteTypeAssocType to carry a single implOrTmTrait node that represents either the trait mention (for <Type as Trait>::AssocType) or the enclosing impl (for Self::AssocType).
  • Reworks the guard logic in getPathConcreteAssocTypeAt to branch based on whether implOrTmTrait is an Impl.
  • Minor comment formatting cleanup in AssociatedType.qll.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
rust/ql/lib/codeql/rust/internal/typeinference/TypeMention.qll Refactors how the “trait mention vs impl context” is represented and used for associated-type resolution.
rust/ql/lib/codeql/rust/internal/typeinference/AssociatedType.qll Reflows an existing doc comment for readability.

Comment on lines +703 to +705
* `implOrTmTrait` is either the mention that resolves to `trait` when `path`
* is of the form `<Type as Trait>::AssocType`, or the enclosing `impl` block
* when `path` is of the form `Self::AssocType`.
Copy link

Copilot AI Mar 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The doc comment describes implOrTmTrait as a “mention”, but the parameter is typed as AstNode and is used as either an Impl node or the trait PathTypeRepr from <Type as Trait>::.... Consider rewording to explicitly mention the concrete AST node kinds (e.g., Impl vs trait PathTypeRepr) to avoid confusion for readers.

Suggested change
* `implOrTmTrait` is either the mention that resolves to `trait` when `path`
* is of the form `<Type as Trait>::AssocType`, or the enclosing `impl` block
* when `path` is of the form `Self::AssocType`.
* `implOrTmTrait` is the AST node corresponding to the trait in the context of
* the access: it is either the trait `PathTypeRepr` from a path of the form
* `<Type as Trait>::AssocType`, or the enclosing `Impl` node when `path` is of
* the form `Self::AssocType`.

Copilot uses AI. Check for mistakes.
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.

2 participants