@@ -63,7 +63,6 @@ use lint;
63
63
use hir:: def:: Def ;
64
64
use hir:: def_id:: DefId ;
65
65
use constrained_type_params as ctp;
66
- use coherence;
67
66
use middle:: lang_items:: SizedTraitLangItem ;
68
67
use middle:: resolve_lifetime;
69
68
use middle:: const_val:: ConstVal ;
@@ -80,13 +79,14 @@ use rscope::*;
80
79
use rustc:: dep_graph:: DepNode ;
81
80
use rustc:: hir:: map as hir_map;
82
81
use util:: common:: { ErrorReported , MemoizationMap } ;
83
- use util:: nodemap:: { FnvHashMap , FnvHashSet } ;
82
+ use util:: nodemap:: FnvHashMap ;
84
83
use write_ty_to_tcx;
85
84
86
85
use rustc_const_math:: ConstInt ;
87
86
88
87
use std:: cell:: RefCell ;
89
88
use std:: collections:: HashSet ;
89
+ use std:: collections:: hash_map:: Entry :: { Occupied , Vacant } ;
90
90
use std:: rc:: Rc ;
91
91
92
92
use syntax:: abi;
@@ -742,16 +742,27 @@ fn convert_item(ccx: &CrateCtxt, it: &hir::Item) {
742
742
743
743
// Convert all the associated consts.
744
744
// 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 ( ) ;
747
747
748
748
for impl_item in impl_items {
749
749
let seen_items = match impl_item. node {
750
750
hir:: ImplItemKind :: Type ( _) => & mut seen_type_items,
751
751
_ => & mut seen_value_items,
752
752
} ;
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
+ }
755
766
}
756
767
757
768
if let hir:: ImplItemKind :: Const ( ref ty, _) = impl_item. node {
0 commit comments