@@ -78,6 +78,7 @@ use std::ops;
78
78
use std:: rc:: Rc ;
79
79
use std:: vec:: IntoIter ;
80
80
use collections:: enum_set:: { self , EnumSet , CLike } ;
81
+ use collections:: slice:: SliceConcatExt ;
81
82
use std:: collections:: { HashMap , HashSet } ;
82
83
use syntax:: abi;
83
84
use syntax:: ast:: { CrateNum , DefId , ItemImpl , ItemTrait , LOCAL_CRATE } ;
@@ -5466,17 +5467,47 @@ impl<'tcx> ctxt<'tcx> {
5466
5467
let expected = values. expected ;
5467
5468
let found = values. found ;
5468
5469
self . sess . span_note ( sp,
5469
- & format ! ( "conflicting type parameter defaults {} and {}" ,
5470
- expected. ty,
5471
- found. ty) ) ;
5472
- self . sess . span_note ( expected. definition_span ,
5473
- & format ! ( "a default was defined here..." ) ) ;
5470
+ & format ! ( "conflicting type parameter defaults `{}` and `{}`" ,
5471
+ expected. ty,
5472
+ found. ty) ) ;
5473
+
5474
+ match ( expected. def_id . krate == ast:: LOCAL_CRATE , self . map . opt_span ( expected. def_id . node ) ) {
5475
+ ( true , Some ( span) ) => {
5476
+ self . sess . span_note ( span,
5477
+ & format ! ( "a default was defined here..." ) ) ;
5478
+ }
5479
+ ( _, _) => {
5480
+ let elems = csearch:: get_item_path ( self , expected. def_id )
5481
+ . into_iter ( )
5482
+ . map ( |p| p. to_string ( ) )
5483
+ . collect :: < Vec < _ > > ( ) ;
5484
+ self . sess . note (
5485
+ & format ! ( "a default is defined on `{}`" ,
5486
+ elems. join( "::" ) ) ) ;
5487
+ }
5488
+ }
5489
+
5474
5490
self . sess . span_note ( expected. origin_span ,
5475
- & format ! ( "...that was applied to an unconstrained type variable here" ) ) ;
5476
- self . sess . span_note ( found. definition_span ,
5477
- & format ! ( "a second default was defined here..." ) ) ;
5491
+ & format ! ( "...that was applied to an unconstrained type variable here" ) ) ;
5492
+
5493
+ match ( found. def_id . krate == ast:: LOCAL_CRATE , self . map . opt_span ( found. def_id . node ) ) {
5494
+ ( true , Some ( span) ) => {
5495
+ self . sess . span_note ( span,
5496
+ & format ! ( "a second default was defined here..." ) ) ;
5497
+ }
5498
+ ( _, _) => {
5499
+ let elems = csearch:: get_item_path ( self , found. def_id )
5500
+ . into_iter ( )
5501
+ . map ( |p| p. to_string ( ) )
5502
+ . collect :: < Vec < _ > > ( ) ;
5503
+
5504
+ self . sess . note (
5505
+ & format ! ( "a second default is defined on `{}`" , elems. join( " " ) ) ) ;
5506
+ }
5507
+ }
5508
+
5478
5509
self . sess . span_note ( found. origin_span ,
5479
- & format ! ( "...that also applies to the same type variable here" ) ) ;
5510
+ & format ! ( "...that also applies to the same type variable here" ) ) ;
5480
5511
}
5481
5512
_ => { }
5482
5513
}
0 commit comments