@@ -63,7 +63,6 @@ use lint;
6363use hir:: def:: Def ;
6464use hir:: def_id:: DefId ;
6565use constrained_type_params as ctp;
66- use coherence;
6766use middle:: lang_items:: SizedTraitLangItem ;
6867use middle:: resolve_lifetime;
6968use middle:: const_val:: ConstVal ;
@@ -80,13 +79,14 @@ use rscope::*;
8079use rustc:: dep_graph:: DepNode ;
8180use rustc:: hir:: map as hir_map;
8281use util:: common:: { ErrorReported , MemoizationMap } ;
83- use util:: nodemap:: { FnvHashMap , FnvHashSet } ;
82+ use util:: nodemap:: FnvHashMap ;
8483use write_ty_to_tcx;
8584
8685use rustc_const_math:: ConstInt ;
8786
8887use std:: cell:: RefCell ;
8988use std:: collections:: HashSet ;
89+ use std:: collections:: hash_map:: Entry :: { Occupied , Vacant } ;
9090use std:: rc:: Rc ;
9191
9292use syntax:: abi;
@@ -742,16 +742,27 @@ fn convert_item(ccx: &CrateCtxt, it: &hir::Item) {
742742
743743 // Convert all the associated consts.
744744 // Also, check if there are any duplicate associated items
745- let mut seen_type_items = FnvHashSet ( ) ;
746- let mut seen_value_items = FnvHashSet ( ) ;
745+ let mut seen_type_items = FnvHashMap ( ) ;
746+ let mut seen_value_items = FnvHashMap ( ) ;
747747
748748 for impl_item in impl_items {
749749 let seen_items = match impl_item. node {
750750 hir:: ImplItemKind :: Type ( _) => & mut seen_type_items,
751751 _ => & mut seen_value_items,
752752 } ;
753- if !seen_items. insert ( impl_item. name ) {
754- coherence:: report_duplicate_item ( tcx, impl_item. span , impl_item. name ) . emit ( ) ;
753+ match seen_items. entry ( impl_item. name ) {
754+ Occupied ( entry) => {
755+ let mut err = struct_span_err ! ( tcx. sess, impl_item. span, E0201 ,
756+ "duplicate definitions with name `{}`:" ,
757+ impl_item. name) ;
758+ span_note ! ( & mut err, * entry. get( ) ,
759+ "previous definition of `{}` here" ,
760+ impl_item. name) ;
761+ err. emit ( ) ;
762+ }
763+ Vacant ( entry) => {
764+ entry. insert ( impl_item. span ) ;
765+ }
755766 }
756767
757768 if let hir:: ImplItemKind :: Const ( ref ty, _) = impl_item. node {
0 commit comments