@@ -747,17 +747,7 @@ fn convert_methods<'a,'tcx,'i,I>(ccx: &CrateCtxt<'a, 'tcx>,
747747 rcvr_ty_generics,
748748 rcvr_ty_predicates) ;
749749
750- let tcx = ccx. tcx ;
751- let mut seen_methods = FnvHashSet ( ) ;
752- for ( sig, id, ident, vis, span) in methods {
753- if !seen_methods. insert ( ident. name ) {
754- let fn_desc = match sig. explicit_self . node {
755- ast:: SelfStatic => "associated function" ,
756- _ => "method" ,
757- } ;
758- span_err ! ( tcx. sess, span, E0201 , "duplicate {}" , fn_desc) ;
759- }
760-
750+ for ( sig, id, ident, vis, _span) in methods {
761751 convert_method ( ccx,
762752 container,
763753 sig,
@@ -859,7 +849,30 @@ fn convert_item(ccx: &CrateCtxt, it: &ast::Item) {
859849 } ;
860850
861851 // Convert all the associated consts.
852+ // Also, check if there are any duplicate associated items
853+ let mut seen_type_items = FnvHashSet ( ) ;
854+ let mut seen_value_items = FnvHashSet ( ) ;
855+
862856 for impl_item in impl_items {
857+ let seen_items = match impl_item. node {
858+ ast:: TypeImplItem ( _) => & mut seen_type_items,
859+ _ => & mut seen_value_items,
860+ } ;
861+ if !seen_items. insert ( impl_item. ident . name ) {
862+ let desc = match impl_item. node {
863+ ast:: ConstImplItem ( _, _) => "associated constant" ,
864+ ast:: TypeImplItem ( _) => "associated type" ,
865+ ast:: MethodImplItem ( ref sig, _) =>
866+ match sig. explicit_self . node {
867+ ast:: SelfStatic => "associated function" ,
868+ _ => "method" ,
869+ } ,
870+ _ => "associated item" ,
871+ } ;
872+
873+ span_err ! ( tcx. sess, impl_item. span, E0201 , "duplicate {}" , desc) ;
874+ }
875+
863876 if let ast:: ConstImplItem ( ref ty, ref expr) = impl_item. node {
864877 let ty = ccx. icx ( & ty_predicates)
865878 . to_ty ( & ExplicitRscope , & * ty) ;
0 commit comments