File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed
compiler/rustc_trait_selection/src/traits/error_reporting Expand file tree Collapse file tree 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> {
36283628 is_derivable_trait &&
36293629 // Ensure all fields impl the trait.
36303630 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) ) ;
36323632 let trait_args = match diagnostic_name {
36333633 sym:: PartialEq | sym:: PartialOrd => {
36343634 Some ( field_ty)
36353635 }
36363636 _ => None ,
36373637 } ;
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] ) ;
36383640 let trait_pred = trait_pred. map_bound_ref ( |tr| ty:: TraitPredicate {
36393641 trait_ref : ty:: TraitRef :: new ( self . tcx ,
36403642 trait_pred. def_id ( ) ,
3641- [ field_ty] . into_iter ( ) . chain ( trait_args) ,
3643+ [ field_ty] . into_iter ( ) . chain ( trait_args) . chain ( host ) ,
36423644 ) ,
36433645 ..* tr
36443646 } ) ;
@@ -3659,6 +3661,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
36593661 trait_pred. skip_binder( ) . self_ty( ) ,
36603662 diagnostic_name,
36613663 ) ,
3664+ // FIXME(effects, const_trait_impl) derive_const as suggestion?
36623665 format ! ( "#[derive({diagnostic_name})]\n " ) ,
36633666 Applicability :: MaybeIncorrect ,
36643667 ) ;
You can’t perform that action at this time.
0 commit comments