mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-14 02:49:40 +00:00
![]() Correctly substitute GAT's type used in `normalize_param_env` in `check_type_bounds` Given: ```rust trait Foo { type Assoc<T>: PartialEq<Self::Assoc<i32>>; } impl Foo for () { type Assoc<T> = Wrapper<T>; } struct Wrapper<T>(T); impl<T> PartialEq<Wrapper<i32>> for Wrapper<T> { } ``` We add an additional predicate in the `normalize_param_env` in `check_type_bounds` that is used to normalize the GAT's bounds to check them in the impl. Problematically, though, that predicate is constructed to be `for<^0> <() as Foo>::Assoc<^0> => Wrapper<T>`, instead of `for<^0> <() as Foo>::Assoc<^0> => Wrapper<^0>`. That means `Self::Assoc<i32>` in the bounds that we're checking normalizes to `Wrapper<T>`, instead of `Wrapper<i32>`, and so the bound `Self::Assoc<T>: PartialEq<Self::Assoc<i32>>` normalizes to `Wrapper<T>: PartialEq<Wrapper<T>>`, which does not hold. Fixes this by properly substituting the RHS of that normalizes predicate that we add to the `normalize_param_env`. That means the bound is properly normalized to `Wrapper<T>: PartialEq<Wrapper<i32>>`, which *does* hold. --- The second commit in this PR just cleans up some substs stuff and some naming. r? `@jackh726` cc #87900 |
||
---|---|---|
.. | ||
check.rs | ||
compare_impl_item.rs | ||
dropck.rs | ||
intrinsic.rs | ||
intrinsicck.rs | ||
mod.rs | ||
region.rs | ||
wfcheck.rs |