Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rustdoc: Remove fake_def_ids RefCell #82382

Merged
merged 1 commit into from
Feb 22, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions src/librustdoc/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ crate struct DocContext<'tcx> {
crate ct_substs: RefCell<FxHashMap<DefId, clean::Constant>>,
/// Table synthetic type parameter for `impl Trait` in argument position -> bounds
crate impl_trait_bounds: RefCell<FxHashMap<ImplTraitParam, Vec<clean::GenericBound>>>,
crate fake_def_ids: RefCell<FxHashMap<CrateNum, DefIndex>>,
crate fake_def_ids: FxHashMap<CrateNum, DefIndex>,
/// Auto-trait or blanket impls processed so far, as `(self_ty, trait_def_id)`.
// FIXME(eddyb) make this a `ty::TraitRef<'tcx>` set.
crate generated_synthetics: RefCell<FxHashSet<(Ty<'tcx>, DefId)>>,
Expand Down Expand Up @@ -140,16 +140,14 @@ impl<'tcx> DocContext<'tcx> {
/// [`RefCell`]: std::cell::RefCell
/// [`Debug`]: std::fmt::Debug
/// [`clean::Item`]: crate::clean::types::Item
crate fn next_def_id(&self, crate_num: CrateNum) -> DefId {
let mut fake_ids = self.fake_def_ids.borrow_mut();

let def_index = match fake_ids.entry(crate_num) {
crate fn next_def_id(&mut self, crate_num: CrateNum) -> DefId {
let def_index = match self.fake_def_ids.entry(crate_num) {
Entry::Vacant(e) => {
let num_def_idx = {
let num_def_idx = if crate_num == LOCAL_CRATE {
self.tcx.hir().definitions().def_path_table().num_def_ids()
} else {
self.enter_resolver(|r| r.cstore().num_def_ids(crate_num))
self.resolver.borrow_mut().access(|r| r.cstore().num_def_ids(crate_num))
};

DefIndex::from_usize(num_def_idx)
Expand Down