@@ -2339,7 +2339,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
2339
2339
Option < ty:: Predicate < ' tcx > > ,
2340
2340
Option < ObligationCause < ' tcx > > ,
2341
2341
) ] ,
2342
- ) -> Vec < ( String , Span , String ) > {
2342
+ ) -> Vec < ( String , Span , Symbol ) > {
2343
2343
let mut derives = Vec :: < ( String , Span , Symbol ) > :: new ( ) ;
2344
2344
let mut traits = Vec :: new ( ) ;
2345
2345
for ( pred, _, _) in unsatisfied_predicates {
@@ -2388,21 +2388,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
2388
2388
traits. sort ( ) ;
2389
2389
traits. dedup ( ) ;
2390
2390
2391
- derives. sort ( ) ;
2392
- derives. dedup ( ) ;
2393
-
2394
- let mut derives_grouped = Vec :: < ( String , Span , String ) > :: new ( ) ;
2395
- for ( self_name, self_span, trait_name) in derives. into_iter ( ) {
2396
- if let Some ( ( last_self_name, _, ref mut last_trait_names) ) = derives_grouped. last_mut ( )
2397
- {
2398
- if last_self_name == & self_name {
2399
- last_trait_names. push_str ( format ! ( ", {trait_name}" ) . as_str ( ) ) ;
2400
- continue ;
2401
- }
2402
- }
2403
- derives_grouped. push ( ( self_name, self_span, trait_name. to_string ( ) ) ) ;
2404
- }
2405
-
2406
2391
let len = traits. len ( ) ;
2407
2392
if len > 0 {
2408
2393
let span =
@@ -2425,10 +2410,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
2425
2410
) ;
2426
2411
}
2427
2412
2428
- derives_grouped
2413
+ derives
2429
2414
}
2430
2415
2431
- pub fn suggest_derive (
2416
+ pub ( crate ) fn suggest_derive (
2432
2417
& self ,
2433
2418
err : & mut Diagnostic ,
2434
2419
unsatisfied_predicates : & [ (
@@ -2437,8 +2422,22 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
2437
2422
Option < ObligationCause < ' tcx > > ,
2438
2423
) ] ,
2439
2424
) {
2440
- let derives_grouped =
2441
- self . note_predicate_source_and_get_derives ( err, unsatisfied_predicates) ;
2425
+ let mut derives = self . note_predicate_source_and_get_derives ( err, unsatisfied_predicates) ;
2426
+ derives. sort ( ) ;
2427
+ derives. dedup ( ) ;
2428
+
2429
+ let mut derives_grouped = Vec :: < ( String , Span , String ) > :: new ( ) ;
2430
+ for ( self_name, self_span, trait_name) in derives. into_iter ( ) {
2431
+ if let Some ( ( last_self_name, _, ref mut last_trait_names) ) = derives_grouped. last_mut ( )
2432
+ {
2433
+ if last_self_name == & self_name {
2434
+ last_trait_names. push_str ( format ! ( ", {trait_name}" ) . as_str ( ) ) ;
2435
+ continue ;
2436
+ }
2437
+ }
2438
+ derives_grouped. push ( ( self_name, self_span, trait_name. to_string ( ) ) ) ;
2439
+ }
2440
+
2442
2441
for ( self_name, self_span, traits) in & derives_grouped {
2443
2442
err. span_suggestion_verbose (
2444
2443
self_span. shrink_to_lo ( ) ,
0 commit comments