resolve: Make bindings from extern prelude unique
instead of creating a new every time a name from extern prelude is accessed
This commit is contained in:
@@ -870,10 +870,7 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
|
||||
let imported_binding = self.r.import(binding, import);
|
||||
if parent == self.r.graph_root {
|
||||
if let Some(entry) = self.r.extern_prelude.get(&ident.normalize_to_macros_2_0()) {
|
||||
if expansion != LocalExpnId::ROOT
|
||||
&& orig_name.is_some()
|
||||
&& entry.extern_crate_item.is_none()
|
||||
{
|
||||
if expansion != LocalExpnId::ROOT && orig_name.is_some() && !entry.is_import() {
|
||||
let msg = "macro-expanded `extern crate` items cannot \
|
||||
shadow names passed with `--extern`";
|
||||
self.r.tcx.sess.span_err(item.span, msg);
|
||||
@@ -884,10 +881,14 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
|
||||
return;
|
||||
}
|
||||
}
|
||||
let entry = self.r.extern_prelude.entry(ident.normalize_to_macros_2_0()).or_insert(
|
||||
ExternPreludeEntry { extern_crate_item: None, introduced_by_item: true },
|
||||
);
|
||||
entry.extern_crate_item = Some(imported_binding);
|
||||
let entry = self
|
||||
.r
|
||||
.extern_prelude
|
||||
.entry(ident.normalize_to_macros_2_0())
|
||||
.or_insert(ExternPreludeEntry { binding: None, introduced_by_item: true });
|
||||
// Binding from `extern crate` item in source code can replace
|
||||
// a binding from `--extern` on command line here.
|
||||
entry.binding = Some(imported_binding);
|
||||
if orig_name.is_some() {
|
||||
entry.introduced_by_item = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user