Skip to content

Commit 3dd303a

Browse files
committed
Rename BoundTyIndex to BoundVar
1 parent d044755 commit 3dd303a

File tree

7 files changed

+27
-27
lines changed

7 files changed

+27
-27
lines changed

src/librustc/ich/impls_ty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ impl<'a> HashStable<StableHashingContext<'a>> for ty::RegionVid {
147147
}
148148
}
149149

150-
impl<'gcx> HashStable<StableHashingContext<'gcx>> for ty::BoundTyIndex {
150+
impl<'gcx> HashStable<StableHashingContext<'gcx>> for ty::BoundVar {
151151
#[inline]
152152
fn hash_stable<W: StableHasherResult>(&self,
153153
hcx: &mut StableHashingContext<'gcx>,

src/librustc/infer/canonical/canonicalizer.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use infer::InferCtxt;
2323
use std::sync::atomic::Ordering;
2424
use ty::fold::{TypeFoldable, TypeFolder};
2525
use ty::subst::Kind;
26-
use ty::{self, BoundTy, BoundTyIndex, Lift, List, Ty, TyCtxt, TypeFlags};
26+
use ty::{self, BoundTy, BoundVar, Lift, List, Ty, TyCtxt, TypeFlags};
2727

2828
use rustc_data_structures::fx::FxHashMap;
2929
use rustc_data_structures::indexed_vec::Idx;
@@ -277,7 +277,7 @@ struct Canonicalizer<'cx, 'gcx: 'tcx, 'tcx: 'cx> {
277277
query_state: &'cx mut OriginalQueryValues<'tcx>,
278278
// Note that indices is only used once `var_values` is big enough to be
279279
// heap-allocated.
280-
indices: FxHashMap<Kind<'tcx>, BoundTyIndex>,
280+
indices: FxHashMap<Kind<'tcx>, BoundVar>,
281281
canonicalize_region_mode: &'cx dyn CanonicalizeRegionMode,
282282
needs_canonical_flags: TypeFlags,
283283
}
@@ -455,7 +455,7 @@ impl<'cx, 'gcx, 'tcx> Canonicalizer<'cx, 'gcx, 'tcx> {
455455
/// or returns an existing variable if `kind` has already been
456456
/// seen. `kind` is expected to be an unbound variable (or
457457
/// potentially a free region).
458-
fn canonical_var(&mut self, info: CanonicalVarInfo, kind: Kind<'tcx>) -> BoundTyIndex {
458+
fn canonical_var(&mut self, info: CanonicalVarInfo, kind: Kind<'tcx>) -> BoundVar {
459459
let Canonicalizer {
460460
variables,
461461
query_state,
@@ -475,7 +475,7 @@ impl<'cx, 'gcx, 'tcx> Canonicalizer<'cx, 'gcx, 'tcx> {
475475
// direct linear search of `var_values`.
476476
if let Some(idx) = var_values.iter().position(|&k| k == kind) {
477477
// `kind` is already present in `var_values`.
478-
BoundTyIndex::new(idx)
478+
BoundVar::new(idx)
479479
} else {
480480
// `kind` isn't present in `var_values`. Append it. Likewise
481481
// for `info` and `variables`.
@@ -490,19 +490,19 @@ impl<'cx, 'gcx, 'tcx> Canonicalizer<'cx, 'gcx, 'tcx> {
490490
*indices = var_values
491491
.iter()
492492
.enumerate()
493-
.map(|(i, &kind)| (kind, BoundTyIndex::new(i)))
493+
.map(|(i, &kind)| (kind, BoundVar::new(i)))
494494
.collect();
495495
}
496496
// The cv is the index of the appended element.
497-
BoundTyIndex::new(var_values.len() - 1)
497+
BoundVar::new(var_values.len() - 1)
498498
}
499499
} else {
500500
// `var_values` is large. Do a hashmap search via `indices`.
501501
*indices.entry(kind).or_insert_with(|| {
502502
variables.push(info);
503503
var_values.push(kind);
504504
assert_eq!(variables.len(), var_values.len());
505-
BoundTyIndex::new(variables.len() - 1)
505+
BoundVar::new(variables.len() - 1)
506506
})
507507
};
508508

src/librustc/infer/canonical/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ use std::ops::Index;
4040
use syntax::source_map::Span;
4141
use ty::fold::TypeFoldable;
4242
use ty::subst::Kind;
43-
use ty::{self, BoundTyIndex, Lift, List, Region, TyCtxt};
43+
use ty::{self, BoundVar, Lift, List, Region, TyCtxt};
4444

4545
mod canonicalizer;
4646

@@ -73,7 +73,7 @@ impl<'gcx> UseSpecializedDecodable for CanonicalVarInfos<'gcx> {}
7373
/// canonicalized query response.
7474
#[derive(Clone, Debug, PartialEq, Eq, Hash, RustcDecodable, RustcEncodable)]
7575
pub struct CanonicalVarValues<'tcx> {
76-
pub var_values: IndexVec<BoundTyIndex, Kind<'tcx>>,
76+
pub var_values: IndexVec<BoundVar, Kind<'tcx>>,
7777
}
7878

7979
/// When we canonicalize a value to form a query, we wind up replacing
@@ -337,7 +337,7 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {
337337
variables: &List<CanonicalVarInfo>,
338338
universe_map: impl Fn(ty::UniverseIndex) -> ty::UniverseIndex,
339339
) -> CanonicalVarValues<'tcx> {
340-
let var_values: IndexVec<BoundTyIndex, Kind<'tcx>> = variables
340+
let var_values: IndexVec<BoundVar, Kind<'tcx>> = variables
341341
.iter()
342342
.map(|info| self.instantiate_canonical_var(span, *info, &universe_map))
343343
.collect();
@@ -456,10 +456,10 @@ BraceStructLiftImpl! {
456456
} where R: Lift<'tcx>
457457
}
458458

459-
impl<'tcx> Index<BoundTyIndex> for CanonicalVarValues<'tcx> {
459+
impl<'tcx> Index<BoundVar> for CanonicalVarValues<'tcx> {
460460
type Output = Kind<'tcx>;
461461

462-
fn index(&self, value: BoundTyIndex) -> &Kind<'tcx> {
462+
fn index(&self, value: BoundVar) -> &Kind<'tcx> {
463463
&self.var_values[value]
464464
}
465465
}

src/librustc/infer/canonical/query_response.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ use traits::{FulfillmentContext, TraitEngine};
3535
use traits::{Obligation, ObligationCause, PredicateObligation};
3636
use ty::fold::TypeFoldable;
3737
use ty::subst::{Kind, UnpackedKind};
38-
use ty::{self, BoundTyIndex, Lift, Ty, TyCtxt};
38+
use ty::{self, BoundVar, Lift, Ty, TyCtxt};
3939

4040
impl<'cx, 'gcx, 'tcx> InferCtxtBuilder<'cx, 'gcx, 'tcx> {
4141
/// The "main method" for a canonicalized trait query. Given the
@@ -273,7 +273,7 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {
273273
for (index, original_value) in original_values.var_values.iter().enumerate() {
274274
// ...with the value `v_r` of that variable from the query.
275275
let result_value = query_response.substitute_projected(self.tcx, &result_subst, |v| {
276-
&v.var_values[BoundTyIndex::new(index)]
276+
&v.var_values[BoundVar::new(index)]
277277
});
278278
match (original_value.unpack(), result_value.unpack()) {
279279
(UnpackedKind::Lifetime(ty::ReErased), UnpackedKind::Lifetime(ty::ReErased)) => {
@@ -423,7 +423,7 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {
423423
// is directly equal to one of the canonical variables in the
424424
// result, then we can type the corresponding value from the
425425
// input. See the example above.
426-
let mut opt_values: IndexVec<BoundTyIndex, Option<Kind<'tcx>>> =
426+
let mut opt_values: IndexVec<BoundVar, Option<Kind<'tcx>>> =
427427
IndexVec::from_elem_n(None, query_response.variables.len());
428428

429429
// In terms of our example above, we are iterating over pairs like:
@@ -457,7 +457,7 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {
457457
.enumerate()
458458
.map(|(index, info)| {
459459
if info.is_existential() {
460-
match opt_values[BoundTyIndex::new(index)] {
460+
match opt_values[BoundVar::new(index)] {
461461
Some(k) => k,
462462
None => self.instantiate_canonical_var(cause.span, *info, |u| {
463463
universe_map[u.as_usize()]
@@ -496,7 +496,7 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {
496496
// canonical variable; this is taken from
497497
// `query_response.var_values` after applying the substitution
498498
// `result_subst`.
499-
let substituted_query_response = |index: BoundTyIndex| -> Kind<'tcx> {
499+
let substituted_query_response = |index: BoundVar| -> Kind<'tcx> {
500500
query_response.substitute_projected(self.tcx, &result_subst, |v| &v.var_values[index])
501501
};
502502

@@ -552,12 +552,12 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {
552552
cause: &ObligationCause<'tcx>,
553553
param_env: ty::ParamEnv<'tcx>,
554554
variables1: &OriginalQueryValues<'tcx>,
555-
variables2: impl Fn(BoundTyIndex) -> Kind<'tcx>,
555+
variables2: impl Fn(BoundVar) -> Kind<'tcx>,
556556
) -> InferResult<'tcx, ()> {
557557
self.commit_if_ok(|_| {
558558
let mut obligations = vec![];
559559
for (index, value1) in variables1.var_values.iter().enumerate() {
560-
let value2 = variables2(BoundTyIndex::new(index));
560+
let value2 = variables2(BoundVar::new(index));
561561

562562
match (value1.unpack(), value2.unpack()) {
563563
(UnpackedKind::Type(v1), UnpackedKind::Type(v2)) => {

src/librustc/ty/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ use rustc_data_structures::stable_hasher::{StableHasher, StableHasherResult,
6363

6464
use hir;
6565

66-
pub use self::sty::{Binder, BoundTy, BoundTyKind, BoundTyIndex, DebruijnIndex, INNERMOST};
66+
pub use self::sty::{Binder, BoundTy, BoundTyKind, BoundVar, DebruijnIndex, INNERMOST};
6767
pub use self::sty::{FnSig, GenSig, CanonicalPolyFnSig, PolyFnSig, PolyGenSig};
6868
pub use self::sty::{InferTy, ParamTy, ProjectionTy, ExistentialPredicate};
6969
pub use self::sty::{ClosureSubsts, GeneratorSubsts, UpvarSubsts, TypeAndMut};

src/librustc/ty/sty.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1171,7 +1171,7 @@ pub enum RegionKind {
11711171
ReClosureBound(RegionVid),
11721172

11731173
/// Canonicalized region, used only when preparing a trait query.
1174-
ReCanonical(BoundTyIndex),
1174+
ReCanonical(BoundVar),
11751175
}
11761176

11771177
impl<'tcx> serialize::UseSpecializedDecodable for Region<'tcx> {}
@@ -1225,13 +1225,13 @@ pub enum InferTy {
12251225
}
12261226

12271227
newtype_index! {
1228-
pub struct BoundTyIndex { .. }
1228+
pub struct BoundVar { .. }
12291229
}
12301230

12311231
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, RustcEncodable, RustcDecodable)]
12321232
pub struct BoundTy {
12331233
pub level: DebruijnIndex,
1234-
pub var: BoundTyIndex,
1234+
pub var: BoundVar,
12351235
pub kind: BoundTyKind,
12361236
}
12371237

@@ -1245,7 +1245,7 @@ impl_stable_hash_for!(struct BoundTy { level, var, kind });
12451245
impl_stable_hash_for!(enum self::BoundTyKind { Anon, Param(a) });
12461246

12471247
impl BoundTy {
1248-
pub fn new(level: DebruijnIndex, var: BoundTyIndex) -> Self {
1248+
pub fn new(level: DebruijnIndex, var: BoundVar) -> Self {
12491249
BoundTy {
12501250
level,
12511251
var,

src/librustc/ty/subst.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
use hir::def_id::DefId;
1414
use infer::canonical::Canonical;
15-
use ty::{self, BoundTyIndex, Lift, List, Ty, TyCtxt};
15+
use ty::{self, BoundVar, Lift, List, Ty, TyCtxt};
1616
use ty::fold::{TypeFoldable, TypeFolder, TypeVisitor};
1717

1818
use serialize::{self, Encodable, Encoder, Decodable, Decoder};
@@ -553,7 +553,7 @@ impl CanonicalUserSubsts<'tcx> {
553553
return false;
554554
}
555555

556-
self.value.substs.iter().zip(BoundTyIndex::new(0)..).all(|(kind, cvar)| {
556+
self.value.substs.iter().zip(BoundVar::new(0)..).all(|(kind, cvar)| {
557557
match kind.unpack() {
558558
UnpackedKind::Type(ty) => match ty.sty {
559559
ty::Bound(ref b) => cvar == b.var,

0 commit comments

Comments
 (0)