@@ -971,7 +971,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
971971 "the following trait bounds were not satisfied:\n {bound_list}"
972972 ) ) ;
973973 }
974- self . suggest_derive ( & mut err, unsatisfied_predicates) ;
974+ self . suggest_derive ( & mut err, unsatisfied_predicates, true ) ;
975975
976976 unsatisfied_bounds = true ;
977977 }
@@ -2252,6 +2252,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
22522252 & self ,
22532253 err : & mut Diagnostic ,
22542254 errors : Vec < FulfillmentError < ' tcx > > ,
2255+ suggest_derive : bool ,
22552256 ) {
22562257 let all_local_types_needing_impls =
22572258 errors. iter ( ) . all ( |e| match e. obligation . predicate . kind ( ) . skip_binder ( ) {
@@ -2322,7 +2323,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
23222323 . iter ( )
23232324 . map ( |e| ( e. obligation . predicate , None , Some ( e. obligation . cause . clone ( ) ) ) )
23242325 . collect ( ) ;
2325- self . suggest_derive ( err, & preds) ;
2326+ self . suggest_derive ( err, & preds, suggest_derive ) ;
23262327 }
23272328
23282329 pub fn suggest_derive (
@@ -2333,6 +2334,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
23332334 Option < ty:: Predicate < ' tcx > > ,
23342335 Option < ObligationCause < ' tcx > > ,
23352336 ) ] ,
2337+ suggest_derive : bool ,
23362338 ) {
23372339 let mut derives = Vec :: < ( String , Span , Symbol ) > :: new ( ) ;
23382340 let mut traits = Vec :: new ( ) ;
@@ -2419,6 +2421,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
24192421 ) ;
24202422 }
24212423
2424+ if !suggest_derive {
2425+ return ;
2426+ }
24222427 for ( self_name, self_span, traits) in & derives_grouped {
24232428 err. span_suggestion_verbose (
24242429 self_span. shrink_to_lo ( ) ,
0 commit comments