Skip to content

Use indexmap::Index{Map,Set} in the compiler instead of Vec+reverse map. #60608

Closed
@eddyb

Description

@eddyb

Examples of pairs of fields we can replace:

rust/src/librustc/ty/mod.rs

Lines 905 to 909 in c6ac575

pub params: Vec<GenericParamDef>,
/// Reverse map to the `index` field of each `GenericParamDef`
#[stable_hasher(ignore)]
pub param_def_id_to_index: FxHashMap<DefId, u32>,

names: FxHashMap<&'static str, Symbol>,
strings: Vec<&'static str>,

spans: FxHashMap<SpanData, u32>,
span_data: Vec<SpanData>,

(any interner that relies on indices can be switched to IndexSet, really)

We could also wrap Index{Set,Map}, like IndexedVec wraps Vec, to use non-usize indices.
(Or we could make our own that stores indices smaller than usize, not sure how much work that is, or if we want to do it at all, cc @bluss)

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-cleanupCategory: PRs that clean code up or issues documenting cleanup.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions