@@ -21,7 +21,7 @@ use rustc::ty;
2121use rustc:: lint:: builtin:: PRIVATE_IN_PUBLIC ;
2222use rustc:: hir:: def_id:: DefId ;
2323use rustc:: hir:: def:: * ;
24- use rustc:: util:: nodemap:: FxHashSet ;
24+ use rustc:: util:: nodemap:: FxHashMap ;
2525
2626use syntax:: ast:: { Ident , NodeId } ;
2727use syntax:: ext:: base:: Determinacy :: { self , Determined , Undetermined } ;
@@ -763,10 +763,11 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> {
763763 * module. globs . borrow_mut ( ) = Vec :: new ( ) ;
764764
765765 let mut reexports = Vec :: new ( ) ;
766+ let mut exported_macro_names = FxHashMap ( ) ;
766767 if module as * const _ == self . graph_root as * const _ {
767- let mut exported_macro_names = FxHashSet ( ) ;
768- for export in mem :: replace ( & mut self . macro_exports , Vec :: new ( ) ) . into_iter ( ) . rev ( ) {
769- if exported_macro_names. insert ( export. name ) {
768+ let macro_exports = mem :: replace ( & mut self . macro_exports , Vec :: new ( ) ) ;
769+ for export in macro_exports. into_iter ( ) . rev ( ) {
770+ if exported_macro_names. insert ( export. name , export . span ) . is_none ( ) {
770771 reexports. push ( export) ;
771772 }
772773 }
@@ -786,7 +787,17 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> {
786787 if !def. def_id ( ) . is_local ( ) {
787788 self . session . cstore . export_macros ( def. def_id ( ) . krate ) ;
788789 }
789- reexports. push ( Export { name : ident. name , def : def } ) ;
790+ if let Def :: Macro ( ..) = def {
791+ if let Some ( & span) = exported_macro_names. get ( & ident. name ) {
792+ let msg =
793+ format ! ( "a macro named `{}` has already been exported" , ident) ;
794+ self . session . struct_span_err ( span, & msg)
795+ . span_label ( span, & format ! ( "`{}` already exported" , ident) )
796+ . span_note ( binding. span , "previous macro export here" )
797+ . emit ( ) ;
798+ }
799+ }
800+ reexports. push ( Export { name : ident. name , def : def, span : binding. span } ) ;
790801 }
791802 }
792803
0 commit comments