@@ -896,7 +896,8 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
896896 self . r . potentially_unused_imports . push ( import) ;
897897 let imported_binding = self . r . import ( binding, import) ;
898898 if parent == self . r . graph_root {
899- if let Some ( entry) = self . r . extern_prelude . get ( & ident. normalize_to_macros_2_0 ( ) ) {
899+ let ident = ident. normalize_to_macros_2_0 ( ) ;
900+ if let Some ( entry) = self . r . extern_prelude . get ( & ident) {
900901 if expansion != LocalExpnId :: ROOT && orig_name. is_some ( ) && !entry. is_import ( ) {
901902 self . r . dcx ( ) . emit_err (
902903 errors:: MacroExpandedExternCrateCannotShadowExternArguments {
@@ -913,14 +914,21 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
913914 let entry = self
914915 . r
915916 . extern_prelude
916- . entry ( ident. normalize_to_macros_2_0 ( ) )
917+ . entry ( ident)
917918 . or_insert ( ExternPreludeEntry { binding : None , introduced_by_item : true } ) ;
918- // Binding from `extern crate` item in source code can replace
919- // a binding from `--extern` on command line here.
920- entry. binding = Some ( imported_binding) ;
921919 if orig_name. is_some ( ) {
922920 entry. introduced_by_item = true ;
923921 }
922+ // Binding from `extern crate` item in source code can replace
923+ // a binding from `--extern` on command line here.
924+ if !entry. is_import ( ) {
925+ entry. binding = Some ( imported_binding)
926+ } else if ident. name != kw:: Underscore {
927+ self . r . dcx ( ) . span_delayed_bug (
928+ item. span ,
929+ format ! ( "it had been define the external module '{ident}' multiple times" ) ,
930+ ) ;
931+ }
924932 }
925933 self . r . define ( parent, ident, TypeNS , imported_binding) ;
926934 }
0 commit comments