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

Type inference: Improve constraint matching by hvitved · Pull Request #22759 · github/codeql · GitHub

Repository navigation

Type inference: Improve constraint matching - #22759

Merged
hvitved merged 3 commits into
github:mainfrom
hvitved:rust/type-inference-more-bound-resolution
Oct 7, 2026
Merged

hvitved merged 3 commits into
github:mainfrom
hvitved:rust/type-inference-more-bound-resolution

Conversation

hvitved commented Oct 6, 2026 •
edited
Loading

Copy link
Copy Markdown
Contributor

When working on type inference for Unified, I realized that there was a (corner) case that the shared inference library did not support:

mod contextual_bound {
    #[derive(Default)]
    struct S<T>(T);

    struct MyThingB<B>(B);

    trait MyTrait<T> {}

    impl<T> MyTrait<[T; 1]> for MyThingB<T> {}

    fn bar<T1, T2: MyTrait<T1>>(x: T1, y: Option<T2>) {}

    fn test_bar() {
        let x = S(0);
        let z = MyThingB(Default::default()); // unable to infer the type of `z`
        bar([x], Some(z));
    }
}

DCA is uneventful.

github-actions Bot added the Rust Pull requests that update Rust code label Oct 6, 2026
hvitved requested a balanced review from Copilot October 6, 2026 18:11

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

Copilot review overview

🟢 Approval recommended

The focused matching change has regression coverage, and the remaining corrections are documentation-only.

Review effort: Balanced
Findings: 2

Open (2) What changed in this PR

Improves shared type inference when trait constraints contain nested type parameters.

Changes:

  • Adds constraint matching for nested implementation-side type paths.
  • Adds Rust regression cases for direct and array-wrapped trait arguments.
  • Updates generated test expectations.
File Description
shared/​typeinference/​codeql/​typeinference/​internal/​TypeInference.qll Extends constraint matching and documents examples.
rust/​ql/​test/​library-tests/​type-inference/​type-inference.expected Records updated inference results.
rust/​ql/​test/​library-tests/​type-inference/​main.rs Adds contextual trait-bound regression cases.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

hvitved force-pushed the rust/type-inference-more-bound-resolution branch from cd3d056 to 10f6b3b Compare October 6, 2026 18:23
hvitved added the no-change-note-required This PR does not need a change note label Oct 7, 2026
hvitved marked this pull request as ready for review October 7, 2026 07:15
hvitved requested review from a team as code owners October 7, 2026 07:15
hvitved requested a review from paldepind October 7, 2026 07:15
* ```
*
* At `term` = `bar(x, y)`, we have
* At `term` = `bar([x], Some(y))`, we have

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

Was this change intentional? The term here doesn't match the call to bar above? Does the existing example need changing?

Copy link
Copy Markdown
Contributor Author

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

Fixed.

hvitved requested a review from paldepind October 7, 2026 12:06
hvitved merged commit f55585d into github:main Oct 7, 2026
107 of 108 checks passed
hvitved deleted the rust/type-inference-more-bound-resolution branch October 7, 2026 13:20
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.

3 participants


Back | FazBrowse Home | New Git URL