@@ -1114,24 +1114,33 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
11141114
11151115 if !is_implemented {
11161116 if !is_provided {
1117- missing_items. push ( trait_item. name ( ) ) ;
1117+ missing_items. push ( trait_item) ;
11181118 } else if associated_type_overridden {
11191119 invalidated_items. push ( trait_item. name ( ) ) ;
11201120 }
11211121 }
11221122 }
11231123
11241124 if !missing_items. is_empty ( ) {
1125- struct_span_err ! ( tcx. sess, impl_span, E0046 ,
1125+ let mut err = struct_span_err ! ( tcx. sess, impl_span, E0046 ,
11261126 "not all trait items implemented, missing: `{}`" ,
11271127 missing_items. iter( )
1128- . map( |name| name. to_string( ) )
1129- . collect:: <Vec <_>>( ) . join( "`, `" ) )
1130- . span_label ( impl_span, & format ! ( "missing `{}` in implementation" ,
1128+ . map( |trait_item| trait_item . name( ) . to_string( ) )
1129+ . collect:: <Vec <_>>( ) . join( "`, `" ) ) ;
1130+ err . span_label ( impl_span, & format ! ( "missing `{}` in implementation" ,
11311131 missing_items. iter( )
1132- . map( |name| name. to_string( ) )
1133- . collect:: <Vec <_>>( ) . join( "`, `" ) )
1134- ) . emit ( ) ;
1132+ . map( |trait_item| trait_item. name( ) . to_string( ) )
1133+ . collect:: <Vec <_>>( ) . join( "`, `" ) ) ) ;
1134+ for trait_item in missing_items {
1135+ if let Some ( span) = tcx. map . span_if_local ( trait_item. def_id ( ) ) {
1136+ err. span_label ( span, & format ! ( "`{}` from trait" , trait_item. name( ) ) ) ;
1137+ } else {
1138+ err. note ( & format ! ( "`{}` from trait: `{}`" ,
1139+ trait_item. name( ) ,
1140+ signature( trait_item) ) ) ;
1141+ }
1142+ }
1143+ err. emit ( ) ;
11351144 }
11361145
11371146 if !invalidated_items. is_empty ( ) {
@@ -1146,6 +1155,14 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
11461155 }
11471156}
11481157
1158+ fn signature < ' a , ' tcx > ( item : & ty:: ImplOrTraitItem ) -> String {
1159+ match * item {
1160+ ty:: MethodTraitItem ( ref item) => format ! ( "{}" , item. fty. sig. 0 ) ,
1161+ ty:: TypeTraitItem ( ref item) => format ! ( "type {};" , item. name. to_string( ) ) ,
1162+ ty:: ConstTraitItem ( ref item) => format ! ( "const {}: {:?};" , item. name. to_string( ) , item. ty) ,
1163+ }
1164+ }
1165+
11491166/// Checks a constant with a given type.
11501167fn check_const_with_type < ' a , ' tcx > ( ccx : & ' a CrateCtxt < ' a , ' tcx > ,
11511168 expr : & ' tcx hir:: Expr ,
0 commit comments