@@ -971,7 +971,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
971
971
"the following trait bounds were not satisfied:\n {bound_list}"
972
972
) ) ;
973
973
}
974
- self . suggest_derive ( & mut err, unsatisfied_predicates) ;
974
+ self . suggest_derive ( & mut err, unsatisfied_predicates, true ) ;
975
975
976
976
unsatisfied_bounds = true ;
977
977
}
@@ -2252,6 +2252,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
2252
2252
& self ,
2253
2253
err : & mut Diagnostic ,
2254
2254
errors : Vec < FulfillmentError < ' tcx > > ,
2255
+ suggest_derive : bool ,
2255
2256
) {
2256
2257
let all_local_types_needing_impls =
2257
2258
errors. iter ( ) . all ( |e| match e. obligation . predicate . kind ( ) . skip_binder ( ) {
@@ -2322,7 +2323,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
2322
2323
. iter ( )
2323
2324
. map ( |e| ( e. obligation . predicate , None , Some ( e. obligation . cause . clone ( ) ) ) )
2324
2325
. collect ( ) ;
2325
- self . suggest_derive ( err, & preds) ;
2326
+ self . suggest_derive ( err, & preds, suggest_derive ) ;
2326
2327
}
2327
2328
2328
2329
pub fn suggest_derive (
@@ -2333,6 +2334,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
2333
2334
Option < ty:: Predicate < ' tcx > > ,
2334
2335
Option < ObligationCause < ' tcx > > ,
2335
2336
) ] ,
2337
+ suggest_derive : bool ,
2336
2338
) {
2337
2339
let mut derives = Vec :: < ( String , Span , Symbol ) > :: new ( ) ;
2338
2340
let mut traits = Vec :: new ( ) ;
@@ -2419,6 +2421,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
2419
2421
) ;
2420
2422
}
2421
2423
2424
+ if !suggest_derive {
2425
+ return ;
2426
+ }
2422
2427
for ( self_name, self_span, traits) in & derives_grouped {
2423
2428
err. span_suggestion_verbose (
2424
2429
self_span. shrink_to_lo ( ) ,
0 commit comments