fix host param for PartialEq
This commit is contained in:
parent
f635cd2e82
commit
e03c18b1b3
@ -3628,17 +3628,19 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
||||
is_derivable_trait &&
|
||||
// Ensure all fields impl the trait.
|
||||
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 {
|
||||
sym::PartialEq | sym::PartialOrd => {
|
||||
Some(field_ty)
|
||||
}
|
||||
_ => 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 {
|
||||
trait_ref: ty::TraitRef::new(self.tcx,
|
||||
trait_pred.def_id(),
|
||||
[field_ty].into_iter().chain(trait_args),
|
||||
[field_ty].into_iter().chain(trait_args).chain(host),
|
||||
),
|
||||
..*tr
|
||||
});
|
||||
@ -3659,6 +3661,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
||||
trait_pred.skip_binder().self_ty(),
|
||||
diagnostic_name,
|
||||
),
|
||||
// FIXME(effects, const_trait_impl) derive_const as suggestion?
|
||||
format!("#[derive({diagnostic_name})]\n"),
|
||||
Applicability::MaybeIncorrect,
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user