fix host param for PartialEq
This commit is contained in:
@@ -3628,17 +3628,19 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||||||
is_derivable_trait &&
|
is_derivable_trait &&
|
||||||
// Ensure all fields impl the trait.
|
// Ensure all fields impl the trait.
|
||||||
adt.all_fields().all(|field| {
|
adt.all_fields().all(|field| {
|
||||||
let field_ty = field.ty(self.tcx, args);
|
let field_ty = ty::GenericArg::from(field.ty(self.tcx, args));
|
||||||
let trait_args = match diagnostic_name {
|
let trait_args = match diagnostic_name {
|
||||||
sym::PartialEq | sym::PartialOrd => {
|
sym::PartialEq | sym::PartialOrd => {
|
||||||
Some(field_ty)
|
Some(field_ty)
|
||||||
}
|
}
|
||||||
_ => None,
|
_ => None,
|
||||||
};
|
};
|
||||||
|
// Also add host param, if present
|
||||||
|
let host = self.tcx.generics_of(trait_pred.def_id()).host_effect_index.map(|idx| trait_pred.skip_binder().trait_ref.args[idx]);
|
||||||
let trait_pred = trait_pred.map_bound_ref(|tr| ty::TraitPredicate {
|
let trait_pred = trait_pred.map_bound_ref(|tr| ty::TraitPredicate {
|
||||||
trait_ref: ty::TraitRef::new(self.tcx,
|
trait_ref: ty::TraitRef::new(self.tcx,
|
||||||
trait_pred.def_id(),
|
trait_pred.def_id(),
|
||||||
[field_ty].into_iter().chain(trait_args),
|
[field_ty].into_iter().chain(trait_args).chain(host),
|
||||||
),
|
),
|
||||||
..*tr
|
..*tr
|
||||||
});
|
});
|
||||||
@@ -3659,6 +3661,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||||||
trait_pred.skip_binder().self_ty(),
|
trait_pred.skip_binder().self_ty(),
|
||||||
diagnostic_name,
|
diagnostic_name,
|
||||||
),
|
),
|
||||||
|
// FIXME(effects, const_trait_impl) derive_const as suggestion?
|
||||||
format!("#[derive({diagnostic_name})]\n"),
|
format!("#[derive({diagnostic_name})]\n"),
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user