Skip to content

Rust: Implement support for associated types accessed on type parameters#21273

Draft
paldepind wants to merge 2 commits intogithub:mainfrom
paldepind:rust/tp-assoc
Draft

Rust: Implement support for associated types accessed on type parameters#21273
paldepind wants to merge 2 commits intogithub:mainfrom
paldepind:rust/tp-assoc

Conversation

@paldepind
Copy link
Contributor

@paldepind paldepind commented Feb 5, 2026

This PR adds type inference support for signatures where an associated type is accessed on a type paramere, such as in:

fn get_content<T: Trait>(item: &T) -> T::Content { ... }

The idea behind the implementation is to turn T::Content into a type parameter. This is explained in the comment for TypeParamAssociatedTypeTypeParameter

The result is that associated types on type parameters are "lowered" into things that we already handle in type inference. For instance, a bound like T::Output: SomeTrait is just a bound on a type parameter, which we already handle.

@github-actions github-actions bot added the Rust Pull requests that update Rust code label Feb 5, 2026
}

/** Holds if `path` is of the form `<type as trait>::name` */
predicate asTraitPath(Path path, TypeRepr typeRepr, Path traitPath, string name) {

Check warning

Code scanning / CodeQL

Predicates starting with "get" or "as" should return a value Warning

This predicate starts with 'as' but does not return a value.
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.

1 participant