Rename ParamTy::idx to ParamTy::index

This commit is contained in:
varkor 2019-05-06 13:12:04 +01:00
parent 7ac02005f3
commit c3694e5ee6
14 changed files with 24 additions and 27 deletions

View File

@ -1453,7 +1453,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
fn tcx<'b>(&'b self) -> TyCtxt<'b, 'gcx, 'tcx> { self.infcx.tcx } fn tcx<'b>(&'b self) -> TyCtxt<'b, 'gcx, 'tcx> { self.infcx.tcx }
fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> { fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
if let ty::Param(ty::ParamTy {name, ..}) = ty.sty { if let ty::Param(ty::ParamTy {name, .. }) = ty.sty {
let infcx = self.infcx; let infcx = self.infcx;
self.var_map.entry(ty).or_insert_with(|| self.var_map.entry(ty).or_insert_with(||
infcx.next_ty_var( infcx.next_ty_var(

View File

@ -3424,7 +3424,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
let mut found = false; let mut found = false;
for ty in field.walk() { for ty in field.walk() {
if let ty::Param(p) = ty.sty { if let ty::Param(p) = ty.sty {
ty_params.insert(p.idx as usize); ty_params.insert(p.index as usize);
found = true; found = true;
} }
} }

View File

@ -204,7 +204,7 @@ impl<'cx, 'gcx, 'tcx> Elaborator<'cx, 'gcx, 'tcx> {
}, },
Component::Param(p) => { Component::Param(p) => {
let ty = tcx.mk_ty_param(p.idx, p.name); let ty = tcx.mk_ty_param(p.index, p.name);
Some(ty::Predicate::TypeOutlives( Some(ty::Predicate::TypeOutlives(
ty::Binder::dummy(ty::OutlivesPredicate(ty, r_min)))) ty::Binder::dummy(ty::OutlivesPredicate(ty, r_min))))
}, },

View File

@ -2715,10 +2715,8 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
} }
#[inline] #[inline]
pub fn mk_ty_param(self, pub fn mk_ty_param(self, index: u32, name: InternedString) -> Ty<'tcx> {
index: u32, self.mk_ty(Param(ParamTy { index, name: name }))
name: InternedString) -> Ty<'tcx> {
self.mk_ty(Param(ParamTy { idx: index, name: name }))
} }
#[inline] #[inline]

View File

@ -979,7 +979,7 @@ impl<'a, 'gcx, 'tcx> Generics {
param: &ParamTy, param: &ParamTy,
tcx: TyCtxt<'a, 'gcx, 'tcx>) tcx: TyCtxt<'a, 'gcx, 'tcx>)
-> &'tcx GenericParamDef { -> &'tcx GenericParamDef {
if let Some(index) = param.idx.checked_sub(self.parent_count as u32) { if let Some(index) = param.index.checked_sub(self.parent_count as u32) {
let param = &self.params[index as usize]; let param = &self.params[index as usize];
match param.kind { match param.kind {
GenericParamDefKind::Type { .. } => param, GenericParamDefKind::Type { .. } => param,

View File

@ -390,7 +390,7 @@ pub fn super_relate_tys<'a, 'gcx, 'tcx, R>(relation: &mut R,
} }
(&ty::Param(ref a_p), &ty::Param(ref b_p)) (&ty::Param(ref a_p), &ty::Param(ref b_p))
if a_p.idx == b_p.idx => if a_p.index == b_p.index =>
{ {
Ok(a) Ok(a)
} }

View File

@ -240,7 +240,7 @@ impl fmt::Debug for Ty<'tcx> {
impl fmt::Debug for ty::ParamTy { impl fmt::Debug for ty::ParamTy {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}/#{}", self.name, self.idx) write!(f, "{}/#{}", self.name, self.index)
} }
} }

View File

@ -1111,13 +1111,13 @@ pub type CanonicalPolyFnSig<'tcx> = Canonical<'tcx, Binder<FnSig<'tcx>>>;
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord,
Hash, RustcEncodable, RustcDecodable, HashStable)] Hash, RustcEncodable, RustcDecodable, HashStable)]
pub struct ParamTy { pub struct ParamTy {
pub idx: u32, pub index: u32,
pub name: InternedString, pub name: InternedString,
} }
impl<'a, 'gcx, 'tcx> ParamTy { impl<'a, 'gcx, 'tcx> ParamTy {
pub fn new(index: u32, name: InternedString) -> ParamTy { pub fn new(index: u32, name: InternedString) -> ParamTy {
ParamTy { idx: index, name: name } ParamTy { index, name: name }
} }
pub fn for_self() -> ParamTy { pub fn for_self() -> ParamTy {
@ -1129,14 +1129,14 @@ impl<'a, 'gcx, 'tcx> ParamTy {
} }
pub fn to_ty(self, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Ty<'tcx> { pub fn to_ty(self, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Ty<'tcx> {
tcx.mk_ty_param(self.idx, self.name) tcx.mk_ty_param(self.index, self.name)
} }
pub fn is_self(&self) -> bool { pub fn is_self(&self) -> bool {
// FIXME(#50125): Ignoring `Self` with `idx != 0` might lead to weird behavior elsewhere, // FIXME(#50125): Ignoring `Self` with `index != 0` might lead to weird behavior elsewhere,
// but this should only be possible when using `-Z continue-parse-after-error` like // but this should only be possible when using `-Z continue-parse-after-error` like
// `compile-fail/issue-36638.rs`. // `compile-fail/issue-36638.rs`.
self.name == keywords::SelfUpper.name().as_str() && self.idx == 0 self.name == keywords::SelfUpper.name().as_str() && self.index == 0
} }
} }
@ -1763,7 +1763,7 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
pub fn is_param(&self, index: u32) -> bool { pub fn is_param(&self, index: u32) -> bool {
match self.sty { match self.sty {
ty::Param(ref data) => data.idx == index, ty::Param(ref data) => data.index == index,
_ => false, _ => false,
} }
} }

View File

@ -547,7 +547,7 @@ impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for SubstFolder<'a, 'gcx, 'tcx> {
impl<'a, 'gcx, 'tcx> SubstFolder<'a, 'gcx, 'tcx> { impl<'a, 'gcx, 'tcx> SubstFolder<'a, 'gcx, 'tcx> {
fn ty_for_param(&self, p: ty::ParamTy, source_ty: Ty<'tcx>) -> Ty<'tcx> { fn ty_for_param(&self, p: ty::ParamTy, source_ty: Ty<'tcx>) -> Ty<'tcx> {
// Look up the type in the substitutions. It really should be in there. // Look up the type in the substitutions. It really should be in there.
let opt_ty = self.substs.get(p.idx as usize).map(|k| k.unpack()); let opt_ty = self.substs.get(p.index as usize).map(|k| k.unpack());
let ty = match opt_ty { let ty = match opt_ty {
Some(UnpackedKind::Type(ty)) => ty, Some(UnpackedKind::Type(ty)) => ty,
Some(kind) => { Some(kind) => {
@ -558,7 +558,7 @@ impl<'a, 'gcx, 'tcx> SubstFolder<'a, 'gcx, 'tcx> {
when substituting (root type={:?}) substs={:?}", when substituting (root type={:?}) substs={:?}",
p, p,
source_ty, source_ty,
p.idx, p.index,
kind, kind,
self.root_ty, self.root_ty,
self.substs, self.substs,
@ -572,7 +572,7 @@ impl<'a, 'gcx, 'tcx> SubstFolder<'a, 'gcx, 'tcx> {
when substituting (root type={:?}) substs={:?}", when substituting (root type={:?}) substs={:?}",
p, p,
source_ty, source_ty,
p.idx, p.index,
self.root_ty, self.root_ty,
self.substs, self.substs,
); );

View File

@ -757,8 +757,7 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
}); });
} }
fn assemble_inherent_candidates_from_param(&mut self, fn assemble_inherent_candidates_from_param(&mut self, param_ty: ty::ParamTy) {
param_ty: ty::ParamTy) {
// FIXME -- Do we want to commit to this behavior for param bounds? // FIXME -- Do we want to commit to this behavior for param bounds?
let bounds = self.param_env let bounds = self.param_env

View File

@ -5795,9 +5795,9 @@ pub fn check_bounds_are_used<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
let mut types_used = vec![false; own_counts.types]; let mut types_used = vec![false; own_counts.types];
for leaf_ty in ty.walk() { for leaf_ty in ty.walk() {
if let ty::Param(ty::ParamTy { idx, .. }) = leaf_ty.sty { if let ty::Param(ty::ParamTy { index, .. }) = leaf_ty.sty {
debug!("Found use of ty param num {}", idx); debug!("Found use of ty param num {}", index);
types_used[idx as usize - own_counts.lifetimes] = true; types_used[index as usize - own_counts.lifetimes] = true;
} else if let ty::Error = leaf_ty.sty { } else if let ty::Error = leaf_ty.sty {
// If there is already another error, do not emit // If there is already another error, do not emit
// an error for not using a type Parameter. // an error for not using a type Parameter.

View File

@ -494,7 +494,7 @@ fn check_where_clauses<'a, 'gcx, 'fcx, 'tcx>(
impl<'tcx> ty::fold::TypeVisitor<'tcx> for CountParams { impl<'tcx> ty::fold::TypeVisitor<'tcx> for CountParams {
fn visit_ty(&mut self, t: Ty<'tcx>) -> bool { fn visit_ty(&mut self, t: Ty<'tcx>) -> bool {
if let ty::Param(param) = t.sty { if let ty::Param(param) = t.sty {
self.params.insert(param.idx); self.params.insert(param.index);
} }
t.super_visit_with(self) t.super_visit_with(self)
} }

View File

@ -8,7 +8,7 @@ use syntax::source_map::Span;
pub struct Parameter(pub u32); pub struct Parameter(pub u32);
impl From<ty::ParamTy> for Parameter { impl From<ty::ParamTy> for Parameter {
fn from(param: ty::ParamTy) -> Self { Parameter(param.idx) } fn from(param: ty::ParamTy) -> Self { Parameter(param.index) }
} }
impl From<ty::EarlyBoundRegion> for Parameter { impl From<ty::EarlyBoundRegion> for Parameter {

View File

@ -324,7 +324,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
} }
ty::Param(ref data) => { ty::Param(ref data) => {
self.add_constraint(current, data.idx, variance); self.add_constraint(current, data.index, variance);
} }
ty::FnPtr(sig) => { ty::FnPtr(sig) => {