From 08284449a24f28ca9d76b8ccd823bc59ed2b30e3 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Wed, 22 Mar 2023 04:32:23 +0000 Subject: [PATCH] Subst gat normalize pred correctly --- .../src/check/compare_impl_item.rs | 2 +- .../gat-bounds-normalize-pred.rs | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 tests/ui/generic-associated-types/gat-bounds-normalize-pred.rs diff --git a/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs b/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs index 49665525967..fd89a2067b7 100644 --- a/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs +++ b/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs @@ -1958,7 +1958,7 @@ pub(super) fn check_type_bounds<'tcx>( let container_id = impl_ty.container_id(tcx); let rebased_substs = impl_ty_substs.rebase_onto(tcx, container_id, impl_trait_ref.substs); - let impl_ty_value = tcx.type_of(impl_ty.def_id).subst_identity(); + let impl_ty_value = tcx.type_of(impl_ty.def_id).subst(tcx, impl_ty_substs); let param_env = tcx.param_env(impl_ty.def_id); diff --git a/tests/ui/generic-associated-types/gat-bounds-normalize-pred.rs b/tests/ui/generic-associated-types/gat-bounds-normalize-pred.rs new file mode 100644 index 00000000000..b43f982283b --- /dev/null +++ b/tests/ui/generic-associated-types/gat-bounds-normalize-pred.rs @@ -0,0 +1,17 @@ +// check-pass + +trait Foo { + type Assoc: PartialEq>; +} + +impl Foo for () { + type Assoc = Wrapper; +} + +struct Wrapper(T); + +impl PartialEq> for Wrapper { + fn eq(&self, _other: &Wrapper) -> bool { true } +} + +fn main() {}