rust-lang / trait-system-refactor-initiative

The Rustc Trait System Refactor Initiative
21 stars 0 forks source link

removing eager infer var replacement improves type inference #81

Open lcnr opened 10 months ago

lcnr commented 10 months ago

the following test compiles with the new solver, but not with the old one. This now works because we don't do eager infer var replacement and use deferred projection equality.

trait Id {
    type Assoc;
}

impl<T> Id for T {
    type Assoc = T;
}

trait Trait<T> {}
impl Trait<u32> for Vec<u32> {}
impl Trait<i32> for Vec<u32> {}

fn assoc_pair<T: Id>() -> Option<*mut (Vec<T>, T::Assoc)> {
    None
}

fn impls_trait<T: Trait<U>, U>(_: Option<*mut (T, U)>) {}

fn main() {
    impls_trait(assoc_pair());
}