@@ -101,6 +101,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
101101 self . autoderef ( span, ty) . any ( |( ty, _) | matches ! ( ty. kind( ) , ty:: Slice ( ..) | ty:: Array ( ..) ) )
102102 }
103103
104+ #[ instrument( level = "debug" , skip( self ) ) ]
104105 pub fn report_method_error (
105106 & self ,
106107 span : Span ,
@@ -587,21 +588,18 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
587588 // Find all the requirements that come from a local `impl` block.
588589 let mut skip_list: FxHashSet < _ > = Default :: default ( ) ;
589590 let mut spanned_predicates: FxHashMap < MultiSpan , _ > = Default :: default ( ) ;
590- for ( data , p, parent_p, impl_def_id, cause) in unsatisfied_predicates
591+ for ( p, parent_p, impl_def_id, cause) in unsatisfied_predicates
591592 . iter ( )
592593 . filter_map ( |( p, parent, c) | c. as_ref ( ) . map ( |c| ( p, parent, c) ) )
593594 . filter_map ( |( p, parent, c) | match c. code ( ) {
594- ObligationCauseCode :: ImplDerivedObligation ( data) => {
595- Some ( ( & data. derived , p, parent, data. impl_def_id , data) )
595+ ObligationCauseCode :: ImplDerivedObligation ( data)
596+ if matches ! ( p. kind( ) . skip_binder( ) , ty:: PredicateKind :: Clause ( _) ) =>
597+ {
598+ Some ( ( p, parent, data. impl_def_id , data) )
596599 }
597600 _ => None ,
598601 } )
599602 {
600- let parent_trait_ref = data. parent_trait_pred ;
601- let path = parent_trait_ref. print_modifiers_and_trait_path ( ) ;
602- let tr_self_ty = parent_trait_ref. skip_binder ( ) . self_ty ( ) ;
603- let unsatisfied_msg = "unsatisfied trait bound introduced here" ;
604- let derive_msg = "unsatisfied trait bound introduced in this `derive` macro" ;
605603 match self . tcx . hir ( ) . get_if_local ( impl_def_id) {
606604 // Unmet obligation comes from a `derive` macro, point at it once to
607605 // avoid multiple span labels pointing at the same place.
@@ -618,9 +616,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
618616 {
619617 let span = self_ty. span . ctxt ( ) . outer_expn_data ( ) . call_site ;
620618 let mut spans: MultiSpan = span. into ( ) ;
621- spans. push_span_label ( span, derive_msg) ;
619+ spans. push_span_label (
620+ span,
621+ "unsatisfied trait bound introduced in this `derive` macro" ,
622+ ) ;
622623 let entry = spanned_predicates. entry ( spans) ;
623- entry. or_insert_with ( || ( path , tr_self_ty , Vec :: new ( ) ) ) . 2 . push ( p) ;
624+ entry. or_insert_with ( || Vec :: new ( ) ) . push ( p) ;
624625 }
625626
626627 // Unmet obligation coming from an `impl`.
@@ -647,8 +648,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
647648 } ;
648649 err. span_suggestion_verbose (
649650 sp,
650- "consider relaxing the type parameter's implicit \
651- `Sized` bound",
651+ "consider relaxing the type parameter's implicit `Sized` bound" ,
652652 sugg,
653653 Applicability :: MachineApplicable ,
654654 ) ;
@@ -661,7 +661,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
661661 skip_list. insert ( p) ;
662662 let mut spans = if cause. span != * item_span {
663663 let mut spans: MultiSpan = cause. span . into ( ) ;
664- spans. push_span_label ( cause. span , unsatisfied_msg) ;
664+ spans. push_span_label (
665+ cause. span ,
666+ "unsatisfied trait bound introduced here" ,
667+ ) ;
665668 spans
666669 } else {
667670 let mut spans = Vec :: with_capacity ( 2 ) ;
@@ -677,7 +680,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
677680 spans. push_span_label ( self_ty. span , "" ) ;
678681
679682 let entry = spanned_predicates. entry ( spans) ;
680- entry. or_insert_with ( || ( path , tr_self_ty , Vec :: new ( ) ) ) . 2 . push ( p) ;
683+ entry. or_insert_with ( || Vec :: new ( ) ) . push ( p) ;
681684 }
682685 Some ( Node :: Item ( hir:: Item {
683686 kind : hir:: ItemKind :: Trait ( rustc_ast:: ast:: IsAuto :: Yes , ..) ,
@@ -694,11 +697,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
694697 }
695698 }
696699 let mut spanned_predicates: Vec < _ > = spanned_predicates. into_iter ( ) . collect ( ) ;
697- spanned_predicates. sort_by_key ( |( span, ( _ , _ , _ ) ) | span. primary_span ( ) ) ;
698- for ( span, ( _path , _self_ty , preds ) ) in spanned_predicates {
699- let mut preds: Vec < _ > = preds
700- . into_iter ( )
701- . filter_map ( |pred| format_pred ( * pred) )
700+ spanned_predicates. sort_by_key ( |( span, _ ) | span. primary_span ( ) ) ;
701+ for ( span, predicates ) in spanned_predicates {
702+ let mut preds: Vec < _ > = predicates
703+ . iter ( )
704+ . filter_map ( |pred| format_pred ( * * pred) )
702705 . map ( |( p, _) | format ! ( "`{}`" , p) )
703706 . collect ( ) ;
704707 preds. sort ( ) ;
0 commit comments