File tree 1 file changed +5
-2
lines changed
compiler/rustc_trait_selection/src/traits/error_reporting
1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -3628,17 +3628,19 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
3628
3628
is_derivable_trait &&
3629
3629
// Ensure all fields impl the trait.
3630
3630
adt. all_fields ( ) . all ( |field| {
3631
- let field_ty = field. ty ( self . tcx , args) ;
3631
+ let field_ty = ty :: GenericArg :: from ( field. ty ( self . tcx , args) ) ;
3632
3632
let trait_args = match diagnostic_name {
3633
3633
sym:: PartialEq | sym:: PartialOrd => {
3634
3634
Some ( field_ty)
3635
3635
}
3636
3636
_ => None ,
3637
3637
} ;
3638
+ // Also add host param, if present
3639
+ let host = self . tcx . generics_of ( trait_pred. def_id ( ) ) . host_effect_index . map ( |idx| trait_pred. skip_binder ( ) . trait_ref . args [ idx] ) ;
3638
3640
let trait_pred = trait_pred. map_bound_ref ( |tr| ty:: TraitPredicate {
3639
3641
trait_ref : ty:: TraitRef :: new ( self . tcx ,
3640
3642
trait_pred. def_id ( ) ,
3641
- [ field_ty] . into_iter ( ) . chain ( trait_args) ,
3643
+ [ field_ty] . into_iter ( ) . chain ( trait_args) . chain ( host ) ,
3642
3644
) ,
3643
3645
..* tr
3644
3646
} ) ;
@@ -3659,6 +3661,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
3659
3661
trait_pred. skip_binder( ) . self_ty( ) ,
3660
3662
diagnostic_name,
3661
3663
) ,
3664
+ // FIXME(effects, const_trait_impl) derive_const as suggestion?
3662
3665
format ! ( "#[derive({diagnostic_name})]\n " ) ,
3663
3666
Applicability :: MaybeIncorrect ,
3664
3667
) ;
You can’t perform that action at this time.
0 commit comments