"Cachify" ExternPreludeEntry.binding through a Cell.
This commit is contained in:
@@ -984,18 +984,17 @@ impl<'a, 'ra, 'tcx> BuildReducedGraphVisitor<'a, 'ra, 'tcx> {
|
|||||||
// more details: https://github.com/rust-lang/rust/pull/111761
|
// more details: https://github.com/rust-lang/rust/pull/111761
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let entry = self
|
let entry = self.r.extern_prelude.entry(ident).or_insert(ExternPreludeEntry {
|
||||||
.r
|
binding: Cell::new(None),
|
||||||
.extern_prelude
|
introduced_by_item: true,
|
||||||
.entry(ident)
|
});
|
||||||
.or_insert(ExternPreludeEntry { binding: None, introduced_by_item: true });
|
|
||||||
if orig_name.is_some() {
|
if orig_name.is_some() {
|
||||||
entry.introduced_by_item = true;
|
entry.introduced_by_item = true;
|
||||||
}
|
}
|
||||||
// Binding from `extern crate` item in source code can replace
|
// Binding from `extern crate` item in source code can replace
|
||||||
// a binding from `--extern` on command line here.
|
// a binding from `--extern` on command line here.
|
||||||
if !entry.is_import() {
|
if !entry.is_import() {
|
||||||
entry.binding = Some(imported_binding)
|
entry.binding.set(Some(imported_binding));
|
||||||
} else if ident.name != kw::Underscore {
|
} else if ident.name != kw::Underscore {
|
||||||
self.r.dcx().span_delayed_bug(
|
self.r.dcx().span_delayed_bug(
|
||||||
item.span,
|
item.span,
|
||||||
|
|||||||
@@ -1009,13 +1009,13 @@ impl<'ra> NameBindingData<'ra> {
|
|||||||
|
|
||||||
#[derive(Default, Clone)]
|
#[derive(Default, Clone)]
|
||||||
struct ExternPreludeEntry<'ra> {
|
struct ExternPreludeEntry<'ra> {
|
||||||
binding: Option<NameBinding<'ra>>,
|
binding: Cell<Option<NameBinding<'ra>>>,
|
||||||
introduced_by_item: bool,
|
introduced_by_item: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ExternPreludeEntry<'_> {
|
impl ExternPreludeEntry<'_> {
|
||||||
fn is_import(&self) -> bool {
|
fn is_import(&self) -> bool {
|
||||||
self.binding.is_some_and(|binding| binding.is_import())
|
self.binding.get().is_some_and(|binding| binding.is_import())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2006,7 +2006,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
|
|||||||
// but not introduce it, as used if they are accessed from lexical scope.
|
// but not introduce it, as used if they are accessed from lexical scope.
|
||||||
if used == Used::Scope {
|
if used == Used::Scope {
|
||||||
if let Some(entry) = self.extern_prelude.get(&ident.normalize_to_macros_2_0()) {
|
if let Some(entry) = self.extern_prelude.get(&ident.normalize_to_macros_2_0()) {
|
||||||
if !entry.introduced_by_item && entry.binding == Some(used_binding) {
|
if !entry.introduced_by_item && entry.binding.get() == Some(used_binding) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2170,7 +2170,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
|
|||||||
|
|
||||||
let norm_ident = ident.normalize_to_macros_2_0();
|
let norm_ident = ident.normalize_to_macros_2_0();
|
||||||
let binding = self.extern_prelude.get(&norm_ident).cloned().and_then(|entry| {
|
let binding = self.extern_prelude.get(&norm_ident).cloned().and_then(|entry| {
|
||||||
Some(if let Some(binding) = entry.binding {
|
Some(if let Some(binding) = entry.binding.get() {
|
||||||
if finalize {
|
if finalize {
|
||||||
if !entry.is_import() {
|
if !entry.is_import() {
|
||||||
self.cstore_mut().process_path_extern(self.tcx, ident.name, ident.span);
|
self.cstore_mut().process_path_extern(self.tcx, ident.name, ident.span);
|
||||||
@@ -2195,8 +2195,8 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
|
|||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
if let Some(entry) = self.extern_prelude.get_mut(&norm_ident) {
|
if let Some(entry) = self.extern_prelude.get(&norm_ident) {
|
||||||
entry.binding = binding;
|
entry.binding.set(binding);
|
||||||
}
|
}
|
||||||
|
|
||||||
binding
|
binding
|
||||||
|
|||||||
Reference in New Issue
Block a user