@@ -2339,7 +2339,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
23392339 Option < ty:: Predicate < ' tcx > > ,
23402340 Option < ObligationCause < ' tcx > > ,
23412341 ) ] ,
2342- ) -> Vec < ( String , Span , String ) > {
2342+ ) -> Vec < ( String , Span , Symbol ) > {
23432343 let mut derives = Vec :: < ( String , Span , Symbol ) > :: new ( ) ;
23442344 let mut traits = Vec :: new ( ) ;
23452345 for ( pred, _, _) in unsatisfied_predicates {
@@ -2388,21 +2388,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
23882388 traits. sort ( ) ;
23892389 traits. dedup ( ) ;
23902390
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-
24062391 let len = traits. len ( ) ;
24072392 if len > 0 {
24082393 let span =
@@ -2425,10 +2410,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
24252410 ) ;
24262411 }
24272412
2428- derives_grouped
2413+ derives
24292414 }
24302415
2431- pub fn suggest_derive (
2416+ pub ( crate ) fn suggest_derive (
24322417 & self ,
24332418 err : & mut Diagnostic ,
24342419 unsatisfied_predicates : & [ (
@@ -2437,8 +2422,22 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
24372422 Option < ObligationCause < ' tcx > > ,
24382423 ) ] ,
24392424 ) {
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+
24422441 for ( self_name, self_span, traits) in & derives_grouped {
24432442 err. span_suggestion_verbose (
24442443 self_span. shrink_to_lo ( ) ,
0 commit comments