Skip to content

identifying which method will run for a trait #716

Open
@nikomatsakis

Description

@nikomatsakis

As part of rust-lang/rust-analyzer#4558, we would like to extend chalk so that it can identify the fn that will run. The basic idea is to model this in a similar fashion to how associated type normalization works.

Summary of the idea

Given:

impl<A> Foo for Bar<A> {
    fn method(&self) { }
}

where method has the type FnDef(X, [_]) we will generate a program clause like

forall<A> {
    NormalizeFn(<Foo as Bar<A>>::method => FnDef(X, [A]))
}

Rust-analyzer can then do a query like NormalizeFn(<Foo as Bar<u32>>::method => ?X) to find the FnDef type for the method that will run (which includes its unique id and the values of all its relevant type parameters).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions