Skip to content

impls with higher ranked projections are now usable #9

Open
@lcnr

Description

@lcnr
trait Trait {}

trait OtherTrait {
    type Assoc<'a>;
}

impl<T: OtherTrait> Trait for (T, for<'a> fn(<T as OtherTrait>::Assoc<'a>)) {}

impl OtherTrait for u32 {
    type Assoc<'a> = &'a u32;
}

fn impls<T: Trait>() {}

fn main() {
    impls::<(u32, for<'a> fn(&'a u32))>();
}

This does not work with the old solver but will compile with the new solver. In the old solver we are unable to eagerly normalize <T as OtherTrait>::Assoc<'a> and also can't replace it with an inference variable (as it contains a bound variable), so then after constraining T the projection is still treated as rigid, even though it is now concrete.

This means that rust-lang/rust#105787 will end up being exploitable with the new solver which is not great 🤷

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions