Closed
Description
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