Skip to content

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

Closed
@edwardw

Description

@edwardw

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions