@@ -192,23 +192,28 @@ impl NiceRegionError<'me, 'tcx> {
192192 vid, sub_placeholder, sup_placeholder, trait_def_id, expected_substs, actual_substs
193193 ) ;
194194
195- let mut err = self . tcx ( ) . sess . struct_span_err (
196- cause. span ( self . tcx ( ) ) ,
197- & format ! (
198- "implementation of `{}` is not general enough" ,
199- self . tcx( ) . def_path_str( trait_def_id) ,
200- ) ,
195+ let span = cause. span ( self . tcx ( ) ) ;
196+ let msg = format ! (
197+ "implementation of `{}` is not general enough" ,
198+ self . tcx( ) . def_path_str( trait_def_id) ,
199+ ) ;
200+ let mut err = self . tcx ( ) . sess . struct_span_err ( span, & msg) ;
201+ err. span_label (
202+ self . tcx ( ) . def_span ( trait_def_id) ,
203+ format ! ( "trait `{}` defined here" , self . tcx( ) . def_path_str( trait_def_id) ) ,
201204 ) ;
202205
203- match cause. code {
204- ObligationCauseCode :: ItemObligation ( def_id) => {
205- err. note ( & format ! (
206- "Due to a where-clause on `{}`," ,
207- self . tcx( ) . def_path_str( def_id) ,
208- ) ) ;
209- }
210- _ => ( ) ,
211- }
206+ let leading_ellipsis = if let ObligationCauseCode :: ItemObligation ( def_id) = cause. code {
207+ err. span_label ( span, "doesn't satisfy where-clause" ) ;
208+ err. span_label (
209+ self . tcx ( ) . def_span ( def_id) ,
210+ & format ! ( "due to a where-clause on `{}`..." , self . tcx( ) . def_path_str( def_id) ) ,
211+ ) ;
212+ true
213+ } else {
214+ err. span_label ( span, & msg) ;
215+ false
216+ } ;
212217
213218 let expected_trait_ref = self . infcx . resolve_vars_if_possible ( & ty:: TraitRef {
214219 def_id : trait_def_id,
@@ -295,6 +300,7 @@ impl NiceRegionError<'me, 'tcx> {
295300 expected_has_vid,
296301 actual_has_vid,
297302 any_self_ty_has_vid,
303+ leading_ellipsis,
298304 ) ;
299305
300306 err
@@ -318,6 +324,7 @@ impl NiceRegionError<'me, 'tcx> {
318324 expected_has_vid : Option < usize > ,
319325 actual_has_vid : Option < usize > ,
320326 any_self_ty_has_vid : bool ,
327+ leading_ellipsis : bool ,
321328 ) {
322329 // HACK(eddyb) maybe move this in a more central location.
323330 #[ derive( Copy , Clone ) ]
@@ -392,13 +399,15 @@ impl NiceRegionError<'me, 'tcx> {
392399
393400 let mut note = if passive_voice {
394401 format ! (
395- "`{}` would have to be implemented for the type `{}`" ,
402+ "{}`{}` would have to be implemented for the type `{}`" ,
403+ if leading_ellipsis { "..." } else { "" } ,
396404 expected_trait_ref,
397405 expected_trait_ref. map( |tr| tr. self_ty( ) ) ,
398406 )
399407 } else {
400408 format ! (
401- "`{}` must implement `{}`" ,
409+ "{}`{}` must implement `{}`" ,
410+ if leading_ellipsis { "..." } else { "" } ,
402411 expected_trait_ref. map( |tr| tr. self_ty( ) ) ,
403412 expected_trait_ref,
404413 )
@@ -407,20 +416,20 @@ impl NiceRegionError<'me, 'tcx> {
407416 match ( has_sub, has_sup) {
408417 ( Some ( n1) , Some ( n2) ) => {
409418 let _ = write ! ( note,
410- ", for any two lifetimes `'{}` and `'{}`" ,
419+ ", for any two lifetimes `'{}` and `'{}`... " ,
411420 std:: cmp:: min( n1, n2) ,
412421 std:: cmp:: max( n1, n2) ,
413422 ) ;
414423 }
415424 ( Some ( n) , _) | ( _, Some ( n) ) => {
416425 let _ = write ! ( note,
417- ", for any lifetime `'{}`" ,
426+ ", for any lifetime `'{}`... " ,
418427 n,
419428 ) ;
420429 }
421430 ( None , None ) => if let Some ( n) = expected_has_vid {
422431 let _ = write ! ( note,
423- ", for some specific lifetime `'{}`" ,
432+ ", for some specific lifetime `'{}`... " ,
424433 n,
425434 ) ;
426435 } ,
@@ -439,13 +448,13 @@ impl NiceRegionError<'me, 'tcx> {
439448
440449 let mut note = if passive_voice {
441450 format ! (
442- "but `{}` is actually implemented for the type `{}`" ,
451+ "... but `{}` is actually implemented for the type `{}`" ,
443452 actual_trait_ref,
444453 actual_trait_ref. map( |tr| tr. self_ty( ) ) ,
445454 )
446455 } else {
447456 format ! (
448- "but `{}` actually implements `{}`" ,
457+ "... but `{}` actually implements `{}`" ,
449458 actual_trait_ref. map( |tr| tr. self_ty( ) ) ,
450459 actual_trait_ref,
451460 )
0 commit comments