mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-29 16:13:40 +00:00
Store next_disambiguator in Definitions.
This commit is contained in:
parent
b29fa94d22
commit
c10a1cebe7
@ -99,6 +99,7 @@ impl DefPathTable {
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Definitions {
|
||||
table: DefPathTable,
|
||||
next_disambiguator: FxHashMap<(LocalDefId, DefPathData), u32>,
|
||||
|
||||
/// Item with a given `LocalDefId` was defined during macro expansion with ID `ExpnId`.
|
||||
expansions_that_defined: FxHashMap<LocalDefId, ExpnId>,
|
||||
@ -340,6 +341,7 @@ impl Definitions {
|
||||
|
||||
Definitions {
|
||||
table,
|
||||
next_disambiguator: Default::default(),
|
||||
expansions_that_defined: Default::default(),
|
||||
def_id_to_span,
|
||||
stable_crate_id,
|
||||
@ -357,7 +359,6 @@ impl Definitions {
|
||||
parent: LocalDefId,
|
||||
data: DefPathData,
|
||||
expn_id: ExpnId,
|
||||
mut next_disambiguator: impl FnMut(LocalDefId, DefPathData) -> u32,
|
||||
span: Span,
|
||||
) -> LocalDefId {
|
||||
debug!("create_def(parent={:?}, data={:?}, expn_id={:?})", parent, data, expn_id);
|
||||
@ -365,7 +366,13 @@ impl Definitions {
|
||||
// The root node must be created with `create_root_def()`.
|
||||
assert!(data != DefPathData::CrateRoot);
|
||||
|
||||
let disambiguator = next_disambiguator(parent, data);
|
||||
// Find the next free disambiguator for this key.
|
||||
let disambiguator = {
|
||||
let next_disamb = self.next_disambiguator.entry((parent, data)).or_insert(0);
|
||||
let disambiguator = *next_disamb;
|
||||
*next_disamb = next_disamb.checked_add(1).expect("disambiguator overflow");
|
||||
disambiguator
|
||||
};
|
||||
let key = DefKey {
|
||||
parent: Some(parent.local_def_index),
|
||||
disambiguated_data: DisambiguatedDefPathData { data, disambiguator },
|
||||
|
@ -1061,7 +1061,6 @@ pub struct Resolver<'a> {
|
||||
/// and how the `impl Trait` fragments were introduced.
|
||||
invocation_parents: FxHashMap<LocalExpnId, (LocalDefId, ImplTraitContext)>,
|
||||
|
||||
next_disambiguator: FxHashMap<(LocalDefId, DefPathData), u32>,
|
||||
/// Some way to know that we are in a *trait* impl in `visit_assoc_item`.
|
||||
/// FIXME: Replace with a more general AST map (together with some other fields).
|
||||
trait_impl_items: FxHashSet<LocalDefId>,
|
||||
@ -1249,16 +1248,7 @@ impl ResolverAstLowering for Resolver<'_> {
|
||||
self.definitions.def_key(self.node_id_to_def_id[&node_id]),
|
||||
);
|
||||
|
||||
// Find the next free disambiguator for this key.
|
||||
let next_disambiguator = &mut self.next_disambiguator;
|
||||
let next_disambiguator = |parent, data| {
|
||||
let next_disamb = next_disambiguator.entry((parent, data)).or_insert(0);
|
||||
let disambiguator = *next_disamb;
|
||||
*next_disamb = next_disamb.checked_add(1).expect("disambiguator overflow");
|
||||
disambiguator
|
||||
};
|
||||
|
||||
let def_id = self.definitions.create_def(parent, data, expn_id, next_disambiguator, span);
|
||||
let def_id = self.definitions.create_def(parent, data, expn_id, span);
|
||||
|
||||
// Some things for which we allocate `LocalDefId`s don't correspond to
|
||||
// anything in the AST, so they don't have a `NodeId`. For these cases
|
||||
@ -1430,7 +1420,6 @@ impl<'a> Resolver<'a> {
|
||||
def_id_to_node_id,
|
||||
placeholder_field_indices: Default::default(),
|
||||
invocation_parents,
|
||||
next_disambiguator: Default::default(),
|
||||
trait_impl_items: Default::default(),
|
||||
legacy_const_generic_args: Default::default(),
|
||||
item_generics_num_lifetimes: Default::default(),
|
||||
|
Loading…
Reference in New Issue
Block a user