Skip to content

Consider implementing "two-dimensional" index for ty::substs #13564

@edwardw

Description

@edwardw
Contributor

One core data structure of rustc is ty::substs:

pub struct substs {
    pub self_ty: Option<ty::t>,
    pub tps: Vec<t>,
    pub regions: RegionSubsts,
}

And, ty::ty_param and ty::ReEarlyBound variants of ty::t and ty::Region have indexes in them:

pub enum Region {
    ReEarlyBound(ast::NodeId, uint, ast::Name),
    ...
}
pub enum sty {
    ty_param(param_ty),
    ...
}
pub struct param_ty {
    pub idx: uint,
    pub def_id: DefId
}

These indexes are meant to distinguish type and lifetime parameters originated from trait, implementation and method bounds. In order to do so, they are monotonic so merging them from different bounds involves messy index manipulation, such as #13503.

@nikomatsakis in IRC:

the fix I had planned was basically to make the index "two-dimensional": that is, first a namespace and then an index
using def-ids would be another option, I tried it once, found it was kinda messy

Activity

edwardw

edwardw commented on Jun 4, 2014

@edwardw
ContributorAuthor

#14604 implements this. So this ticket can be closed as soon as #14604 lands.

nikomatsakis

nikomatsakis commented on Jun 4, 2014

@nikomatsakis
Contributor

@edwardw thanks, I couldn't find this issue when I searched for it. :)

added 5 commits that reference this issue on Jun 4, 2014
ad308b1
1851550
added a commit that references this issue on Nov 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Participants

      @flaper87@nikomatsakis@edwardw

      Issue actions

        Consider implementing "two-dimensional" index for ty::substs · Issue #13564 · rust-lang/rust