@@ -21,7 +21,7 @@ use rustc::ty;
21
21
use rustc:: lint:: builtin:: PRIVATE_IN_PUBLIC ;
22
22
use rustc:: hir:: def_id:: DefId ;
23
23
use rustc:: hir:: def:: * ;
24
- use rustc:: util:: nodemap:: FxHashSet ;
24
+ use rustc:: util:: nodemap:: FxHashMap ;
25
25
26
26
use syntax:: ast:: { Ident , NodeId } ;
27
27
use syntax:: ext:: base:: Determinacy :: { self , Determined , Undetermined } ;
@@ -763,10 +763,11 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> {
763
763
* module. globs . borrow_mut ( ) = Vec :: new ( ) ;
764
764
765
765
let mut reexports = Vec :: new ( ) ;
766
+ let mut exported_macro_names = FxHashMap ( ) ;
766
767
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 ( ) {
770
771
reexports. push ( export) ;
771
772
}
772
773
}
@@ -786,7 +787,17 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> {
786
787
if !def. def_id ( ) . is_local ( ) {
787
788
self . session . cstore . export_macros ( def. def_id ( ) . krate ) ;
788
789
}
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 } ) ;
790
801
}
791
802
}
792
803
0 commit comments