@@ -46,7 +46,7 @@ use ty::subst::Subst;
46
46
use ty:: SubtypePredicate ;
47
47
use util:: nodemap:: { FxHashMap , FxHashSet } ;
48
48
49
- use syntax_pos:: { DUMMY_SP , Span } ;
49
+ use syntax_pos:: { DUMMY_SP , Span , ExpnInfo , ExpnFormat } ;
50
50
51
51
impl < ' a , ' gcx , ' tcx > InferCtxt < ' a , ' gcx , ' tcx > {
52
52
pub fn report_fulfillment_errors ( & self ,
@@ -68,18 +68,30 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
68
68
} ) . collect ( ) ;
69
69
70
70
for ( index, error) in errors. iter ( ) . enumerate ( ) {
71
- error_map. entry ( error. obligation . cause . span ) . or_default ( ) . push (
71
+ // We want to ignore desugarings here: spans are equivalent even
72
+ // if one is the result of a desugaring and the other is not.
73
+ let mut span = error. obligation . cause . span ;
74
+ if let Some ( ExpnInfo {
75
+ format : ExpnFormat :: CompilerDesugaring ( _) ,
76
+ def_site : Some ( def_span) ,
77
+ ..
78
+ } ) = span. ctxt ( ) . outer ( ) . expn_info ( ) {
79
+ span = def_span;
80
+ }
81
+
82
+ error_map. entry ( span) . or_default ( ) . push (
72
83
ErrorDescriptor {
73
84
predicate : error. obligation . predicate . clone ( ) ,
74
85
index : Some ( index)
75
- } ) ;
86
+ }
87
+ ) ;
76
88
77
89
self . reported_trait_errors . borrow_mut ( )
78
- . entry ( error . obligation . cause . span ) . or_default ( )
90
+ . entry ( span) . or_default ( )
79
91
. push ( error. obligation . predicate . clone ( ) ) ;
80
92
}
81
93
82
- // We do this in 2 passes because we want to display errors in order, tho
94
+ // We do this in 2 passes because we want to display errors in order, though
83
95
// maybe it *is* better to sort errors by span or something.
84
96
let mut is_suppressed = vec ! [ false ; errors. len( ) ] ;
85
97
for ( _, error_set) in error_map. iter ( ) {
0 commit comments