FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Rust: Make impl blocks only give rise to direct trait implementation by hvitved · Pull Request #20847 · github/codeql · GitHub

/ codeql Public

Rust: Make impl blocks only give rise to direct trait implementation - #20847

Closed
hvitved wants to merge 5 commits into
github:mainfrom
hvitved:rust/ti-inheritance
Closed

Rust: Make impl blocks only give rise to direct trait implementation#20847
hvitved wants to merge 5 commits into
github:mainfrom
hvitved:rust/ti-inheritance

Conversation

hvitved commented Nov 17, 2025
edited
Loading

Copy link
Copy Markdown
Contributor

Same as #20723, but with merge conflict resolved.

github-actions Bot added the Rust Pull requests that update Rust code label Nov 17, 2025
hvitved added the no-change-note-required This PR does not need a change note label Nov 17, 2025
hvitved marked this pull request as ready for review November 17, 2025 10:40
hvitved requested review from a team as code owners November 17, 2025 10:40
Copilot AI review requested due to automatic review settings November 17, 2025 10:40

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Pull Request Overview

This PR modifies the Rust type inference logic to ensure that impl blocks only establish direct trait implementations rather than transitive ones. The change introduces a transitive boolean parameter to track whether constraint satisfaction should propagate transitively.

Key Changes

  • Added a transitive parameter to conditionSatisfiesConstraint predicate to distinguish direct vs. transitive trait implementations
  • Set transitive=false for impl blocks implementing traits, and transitive=true for other constraint types (supertraits, trait bounds, etc.)
  • Updated function type resolution logic to properly handle trait constraints with the new transitivity semantics

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
shared/typeinference/codeql/typeinference/internal/TypeInference.qll Added transitive parameter to core constraint satisfaction predicate; fixed typo in documentation
rust/ql/lib/codeql/rust/internal/TypeInference.qll Implemented transitive parameter logic for Rust, setting it to false for impl blocks and true for other constraints
rust/ql/lib/codeql/rust/internal/typeinference/FunctionType.qll Updated associated function type resolution to handle transitive constraints; refined type parameter specialization logic
rust/ql/test/library-tests/type-inference/main.rs Removed SPURIOUS annotations from test comments where spurious call targets were eliminated
rust/ql/test/library-tests/type-inference/type-inference.expected Removed spurious type inference results for reference types
rust/ql/test/library-tests/type-inference/CONSISTENCY/PathResolutionConsistency.expected Removed multiple call target warnings that are now resolved
rust/ql/test/library-tests/dataflow/sources/stdin/CONSISTENCY/PathResolutionConsistency.expected Removed resolved multiple call target warning
rust/ql/test/library-tests/dataflow/models/CONSISTENCY/PathResolutionConsistency.expected Removed resolved multiple call target warning

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

Comment on lines +88 to +92
bindingset[abs, constraint, tp]
private Type getTraitConstraintTypeAt(
TypeMention condition, TypeMention constraint, TypeParameter tp, TypePath path
TypeAbstraction abs, TypeMention constraint, TypeParameter tp, TypePath path
) {
BaseTypes::conditionSatisfiesConstraintTypeAt(_, condition, constraint,
BaseTypes::conditionSatisfiesConstraintTypeAt(abs, _, constraint,

Copilot AI Nov 17, 2025

Copy link

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

The bindingset annotation specifies abs, constraint, and tp, but the function call on line 92 passes _ (wildcard) for the second parameter (which would be condition in the called predicate). The annotation should match the parameters that are actually bound in the function body. Since condition is now wildcarded and abs is used instead, verify that the bindingset annotation correctly reflects which parameters are expected to be bound by callers.

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Contributor

@hvitved there was a bug with QLucie which prevernted from reporting back here, sorry about that. The problematic PR was reverted. I will manually trigger a new QLucie run now on this

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
hvitved closed this Nov 17, 2025
hvitved deleted the rust/ti-inheritance branch November 17, 2025 12:36
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

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.

4 participants


Back | FazBrowse Home | New Git URL