rust-lang / trait-system-refactor-initiative

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

Normalizes-to terms equal modulo normalization #86

Closed compiler-errors closed 7 months ago

compiler-errors commented 9 months ago
trait Bar {
    type Item;
    type Assoc: AsRef<[Self::Item]>;
}

struct Foo<T: Bar> {
    t: <T as Bar>::Assoc,
}

impl<T: Bar<Item = u32>> Foo<T>
where
    <T as Bar>::Assoc: AsRef<[u32]>,
{
    fn hello(&self) {
        println!("{}", self.t.as_ref().len());
    }
}

fn main() {}

Since <T as Bar>::Assoc can project to [u32] or <[T as Bar::Item]> (which is [u32]).

I found this in rand-core 0.5.x.

This is not present in the most recent rand-core version afaict, but many crates use rand-core 0.5.x as a dep.

compiler-errors commented 9 months ago

Related #4

Related #84 (the supertrait version of this)

lcnr commented 7 months ago

fixed by https://github.com/rust-lang/rust/pull/119106