@@ -46,7 +46,7 @@ use ty::subst::Subst;
4646use ty:: SubtypePredicate ;
4747use util:: nodemap:: { FxHashMap , FxHashSet } ;
4848
49- use syntax_pos:: { DUMMY_SP , Span } ;
49+ use syntax_pos:: { DUMMY_SP , Span , ExpnInfo , ExpnFormat } ;
5050
5151impl < ' a , ' gcx , ' tcx > InferCtxt < ' a , ' gcx , ' tcx > {
5252 pub fn report_fulfillment_errors ( & self ,
@@ -68,18 +68,30 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
6868 } ) . collect ( ) ;
6969
7070 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 (
7283 ErrorDescriptor {
7384 predicate : error. obligation . predicate . clone ( ) ,
7485 index : Some ( index)
75- } ) ;
86+ }
87+ ) ;
7688
7789 self . reported_trait_errors . borrow_mut ( )
78- . entry ( error . obligation . cause . span ) . or_default ( )
90+ . entry ( span) . or_default ( )
7991 . push ( error. obligation . predicate . clone ( ) ) ;
8092 }
8193
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
8395 // maybe it *is* better to sort errors by span or something.
8496 let mut is_suppressed = vec ! [ false ; errors. len( ) ] ;
8597 for ( _, error_set) in error_map. iter ( ) {
0 commit comments