@@ -574,7 +574,7 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
574
574
import_resolution. id = directive. id ;
575
575
import_resolution. is_public = directive. is_public ;
576
576
577
- self . add_export ( module_, target, & import_resolution) ;
577
+ self . add_export ( module_, target, namespace , & import_resolution) ;
578
578
* used_public = name_binding. is_public ( ) ;
579
579
}
580
580
Failed ( _) => {
@@ -716,7 +716,7 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
716
716
dest_import_resolution. id = id;
717
717
dest_import_resolution. is_public = is_public;
718
718
dest_import_resolution. target = Some ( target. clone ( ) ) ;
719
- self . add_export ( module_, name, & dest_import_resolution) ;
719
+ self . add_export ( module_, name, ns , & dest_import_resolution) ;
720
720
}
721
721
_ => { }
722
722
}
@@ -796,7 +796,7 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
796
796
dest_import_resolution. target = Some ( target) ;
797
797
dest_import_resolution. id = id;
798
798
dest_import_resolution. is_public = is_public;
799
- self . add_export ( module_, name, & dest_import_resolution) ;
799
+ self . add_export ( module_, name, ns , & dest_import_resolution) ;
800
800
}
801
801
} else {
802
802
// FIXME #30159: This is required for backwards compatability.
@@ -809,17 +809,23 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
809
809
( name, ns) ) ;
810
810
}
811
811
812
- fn add_export ( & mut self , module : Module < ' b > , name : Name , resolution : & ImportResolution < ' b > ) {
812
+ fn add_export ( & mut self ,
813
+ module : Module < ' b > ,
814
+ name : Name ,
815
+ ns : Namespace ,
816
+ resolution : & ImportResolution < ' b > ) {
813
817
if !resolution. is_public { return }
814
818
let node_id = match module. def_id ( ) {
815
819
Some ( def_id) => self . resolver . ast_map . as_local_node_id ( def_id) . unwrap ( ) ,
816
820
None => return ,
817
821
} ;
818
822
let export = match resolution. target . as_ref ( ) . unwrap ( ) . binding . def ( ) {
823
+ // A Def::Variant defines both namespaces, so only export it once per name.
824
+ Some ( Def :: Variant ( ..) ) if ns != TypeNS => return ,
819
825
Some ( def) => Export { name : name, def_id : def. def_id ( ) } ,
820
826
None => return ,
821
827
} ;
822
- self . resolver . export_map . entry ( node_id) . or_insert ( Default :: default ( ) ) . insert ( export) ;
828
+ self . resolver . export_map . entry ( node_id) . or_insert ( Vec :: new ( ) ) . push ( export) ;
823
829
}
824
830
825
831
/// Checks that imported names and items don't have the same name.
0 commit comments