Skip to content

Commit c3694e5

Browse files
committed
Rename ParamTy::idx to ParamTy::index
1 parent 7ac0200 commit c3694e5

14 files changed

+24
-27
lines changed

src/librustc/traits/error_reporting.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1453,7 +1453,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
14531453
fn tcx<'b>(&'b self) -> TyCtxt<'b, 'gcx, 'tcx> { self.infcx.tcx }
14541454

14551455
fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
1456-
if let ty::Param(ty::ParamTy {name, ..}) = ty.sty {
1456+
if let ty::Param(ty::ParamTy {name, .. }) = ty.sty {
14571457
let infcx = self.infcx;
14581458
self.var_map.entry(ty).or_insert_with(||
14591459
infcx.next_ty_var(

src/librustc/traits/select.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3424,7 +3424,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
34243424
let mut found = false;
34253425
for ty in field.walk() {
34263426
if let ty::Param(p) = ty.sty {
3427-
ty_params.insert(p.idx as usize);
3427+
ty_params.insert(p.index as usize);
34283428
found = true;
34293429
}
34303430
}

src/librustc/traits/util.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ impl<'cx, 'gcx, 'tcx> Elaborator<'cx, 'gcx, 'tcx> {
204204
},
205205

206206
Component::Param(p) => {
207-
let ty = tcx.mk_ty_param(p.idx, p.name);
207+
let ty = tcx.mk_ty_param(p.index, p.name);
208208
Some(ty::Predicate::TypeOutlives(
209209
ty::Binder::dummy(ty::OutlivesPredicate(ty, r_min))))
210210
},

src/librustc/ty/context.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -2715,10 +2715,8 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
27152715
}
27162716

27172717
#[inline]
2718-
pub fn mk_ty_param(self,
2719-
index: u32,
2720-
name: InternedString) -> Ty<'tcx> {
2721-
self.mk_ty(Param(ParamTy { idx: index, name: name }))
2718+
pub fn mk_ty_param(self, index: u32, name: InternedString) -> Ty<'tcx> {
2719+
self.mk_ty(Param(ParamTy { index, name: name }))
27222720
}
27232721

27242722
#[inline]

src/librustc/ty/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -979,7 +979,7 @@ impl<'a, 'gcx, 'tcx> Generics {
979979
param: &ParamTy,
980980
tcx: TyCtxt<'a, 'gcx, 'tcx>)
981981
-> &'tcx GenericParamDef {
982-
if let Some(index) = param.idx.checked_sub(self.parent_count as u32) {
982+
if let Some(index) = param.index.checked_sub(self.parent_count as u32) {
983983
let param = &self.params[index as usize];
984984
match param.kind {
985985
GenericParamDefKind::Type { .. } => param,

src/librustc/ty/relate.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ pub fn super_relate_tys<'a, 'gcx, 'tcx, R>(relation: &mut R,
390390
}
391391

392392
(&ty::Param(ref a_p), &ty::Param(ref b_p))
393-
if a_p.idx == b_p.idx =>
393+
if a_p.index == b_p.index =>
394394
{
395395
Ok(a)
396396
}

src/librustc/ty/structural_impls.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ impl fmt::Debug for Ty<'tcx> {
240240

241241
impl fmt::Debug for ty::ParamTy {
242242
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
243-
write!(f, "{}/#{}", self.name, self.idx)
243+
write!(f, "{}/#{}", self.name, self.index)
244244
}
245245
}
246246

src/librustc/ty/sty.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -1111,13 +1111,13 @@ pub type CanonicalPolyFnSig<'tcx> = Canonical<'tcx, Binder<FnSig<'tcx>>>;
11111111
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord,
11121112
Hash, RustcEncodable, RustcDecodable, HashStable)]
11131113
pub struct ParamTy {
1114-
pub idx: u32,
1114+
pub index: u32,
11151115
pub name: InternedString,
11161116
}
11171117

11181118
impl<'a, 'gcx, 'tcx> ParamTy {
11191119
pub fn new(index: u32, name: InternedString) -> ParamTy {
1120-
ParamTy { idx: index, name: name }
1120+
ParamTy { index, name: name }
11211121
}
11221122

11231123
pub fn for_self() -> ParamTy {
@@ -1129,14 +1129,14 @@ impl<'a, 'gcx, 'tcx> ParamTy {
11291129
}
11301130

11311131
pub fn to_ty(self, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Ty<'tcx> {
1132-
tcx.mk_ty_param(self.idx, self.name)
1132+
tcx.mk_ty_param(self.index, self.name)
11331133
}
11341134

11351135
pub fn is_self(&self) -> bool {
1136-
// FIXME(#50125): Ignoring `Self` with `idx != 0` might lead to weird behavior elsewhere,
1136+
// FIXME(#50125): Ignoring `Self` with `index != 0` might lead to weird behavior elsewhere,
11371137
// but this should only be possible when using `-Z continue-parse-after-error` like
11381138
// `compile-fail/issue-36638.rs`.
1139-
self.name == keywords::SelfUpper.name().as_str() && self.idx == 0
1139+
self.name == keywords::SelfUpper.name().as_str() && self.index == 0
11401140
}
11411141
}
11421142

@@ -1763,7 +1763,7 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
17631763

17641764
pub fn is_param(&self, index: u32) -> bool {
17651765
match self.sty {
1766-
ty::Param(ref data) => data.idx == index,
1766+
ty::Param(ref data) => data.index == index,
17671767
_ => false,
17681768
}
17691769
}

src/librustc/ty/subst.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for SubstFolder<'a, 'gcx, 'tcx> {
547547
impl<'a, 'gcx, 'tcx> SubstFolder<'a, 'gcx, 'tcx> {
548548
fn ty_for_param(&self, p: ty::ParamTy, source_ty: Ty<'tcx>) -> Ty<'tcx> {
549549
// Look up the type in the substitutions. It really should be in there.
550-
let opt_ty = self.substs.get(p.idx as usize).map(|k| k.unpack());
550+
let opt_ty = self.substs.get(p.index as usize).map(|k| k.unpack());
551551
let ty = match opt_ty {
552552
Some(UnpackedKind::Type(ty)) => ty,
553553
Some(kind) => {
@@ -558,7 +558,7 @@ impl<'a, 'gcx, 'tcx> SubstFolder<'a, 'gcx, 'tcx> {
558558
when substituting (root type={:?}) substs={:?}",
559559
p,
560560
source_ty,
561-
p.idx,
561+
p.index,
562562
kind,
563563
self.root_ty,
564564
self.substs,
@@ -572,7 +572,7 @@ impl<'a, 'gcx, 'tcx> SubstFolder<'a, 'gcx, 'tcx> {
572572
when substituting (root type={:?}) substs={:?}",
573573
p,
574574
source_ty,
575-
p.idx,
575+
p.index,
576576
self.root_ty,
577577
self.substs,
578578
);

src/librustc_typeck/check/method/probe.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -757,8 +757,7 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
757757
});
758758
}
759759

760-
fn assemble_inherent_candidates_from_param(&mut self,
761-
param_ty: ty::ParamTy) {
760+
fn assemble_inherent_candidates_from_param(&mut self, param_ty: ty::ParamTy) {
762761
// FIXME -- Do we want to commit to this behavior for param bounds?
763762

764763
let bounds = self.param_env

src/librustc_typeck/check/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -5795,9 +5795,9 @@ pub fn check_bounds_are_used<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
57955795
let mut types_used = vec![false; own_counts.types];
57965796

57975797
for leaf_ty in ty.walk() {
5798-
if let ty::Param(ty::ParamTy { idx, .. }) = leaf_ty.sty {
5799-
debug!("Found use of ty param num {}", idx);
5800-
types_used[idx as usize - own_counts.lifetimes] = true;
5798+
if let ty::Param(ty::ParamTy { index, .. }) = leaf_ty.sty {
5799+
debug!("Found use of ty param num {}", index);
5800+
types_used[index as usize - own_counts.lifetimes] = true;
58015801
} else if let ty::Error = leaf_ty.sty {
58025802
// If there is already another error, do not emit
58035803
// an error for not using a type Parameter.

src/librustc_typeck/check/wfcheck.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ fn check_where_clauses<'a, 'gcx, 'fcx, 'tcx>(
494494
impl<'tcx> ty::fold::TypeVisitor<'tcx> for CountParams {
495495
fn visit_ty(&mut self, t: Ty<'tcx>) -> bool {
496496
if let ty::Param(param) = t.sty {
497-
self.params.insert(param.idx);
497+
self.params.insert(param.index);
498498
}
499499
t.super_visit_with(self)
500500
}

src/librustc_typeck/constrained_generic_params.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use syntax::source_map::Span;
88
pub struct Parameter(pub u32);
99

1010
impl From<ty::ParamTy> for Parameter {
11-
fn from(param: ty::ParamTy) -> Self { Parameter(param.idx) }
11+
fn from(param: ty::ParamTy) -> Self { Parameter(param.index) }
1212
}
1313

1414
impl From<ty::EarlyBoundRegion> for Parameter {

src/librustc_typeck/variance/constraints.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
324324
}
325325

326326
ty::Param(ref data) => {
327-
self.add_constraint(current, data.idx, variance);
327+
self.add_constraint(current, data.index, variance);
328328
}
329329

330330
ty::FnPtr(sig) => {

0 commit comments

Comments
 (0)