@@ -1114,24 +1114,33 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
1114
1114
1115
1115
if !is_implemented {
1116
1116
if !is_provided {
1117
- missing_items. push ( trait_item. name ( ) ) ;
1117
+ missing_items. push ( trait_item) ;
1118
1118
} else if associated_type_overridden {
1119
1119
invalidated_items. push ( trait_item. name ( ) ) ;
1120
1120
}
1121
1121
}
1122
1122
}
1123
1123
1124
1124
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 ,
1126
1126
"not all trait items implemented, missing: `{}`" ,
1127
1127
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" ,
1131
1131
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 ( ) ;
1135
1144
}
1136
1145
1137
1146
if !invalidated_items. is_empty ( ) {
@@ -1146,6 +1155,14 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
1146
1155
}
1147
1156
}
1148
1157
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
+
1149
1166
/// Checks a constant with a given type.
1150
1167
fn check_const_with_type < ' a , ' tcx > ( ccx : & ' a CrateCtxt < ' a , ' tcx > ,
1151
1168
expr : & ' tcx hir:: Expr ,
0 commit comments