+ // New `ParamEnv` replacing `T: PartialEq` with `T: Eq`
+ let param_env = ParamEnv::new(
+ cx.tcx.mk_predicates(cx.param_env.caller_bounds().iter().map(|p| {
+ let kind = p.kind();
+ match kind.skip_binder() {
+ PredicateKind::Trait(p)
+ if p.trait_ref.def_id == peq_trait_def_id
+ && p.trait_ref.substs.get(0) == p.trait_ref.substs.get(1)
+ && matches!(p.trait_ref.self_ty().kind(), ty::Param(_))
+ && p.constness == BoundConstness::NotConst
+ && p.polarity == ImplPolarity::Positive =>
+ {
+ cx.tcx.mk_predicate(kind.rebind(PredicateKind::Trait(TraitPredicate {
+ trait_ref: TraitRef::new(
+ eq_trait_def_id,
+ cx.tcx.mk_substs([GenericArg::from(p.trait_ref.self_ty())].into_iter()),
+ ),
+ constness: BoundConstness::NotConst,
+ polarity: ImplPolarity::Positive,
+ })))
+ },
+ _ => p,
+ }
+ })),
+ cx.param_env.reveal(),
+ cx.param_env.constness(),
+ );
+ if !implements_trait_with_env(cx.tcx, param_env, ty, eq_trait_def_id, substs);