mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-30 10:45:18 +00:00
Rename BoundTyIndex
to BoundVar
This commit is contained in:
parent
d0447550da
commit
3dd303aa89
@ -147,7 +147,7 @@ impl<'a> HashStable<StableHashingContext<'a>> for ty::RegionVid {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'gcx> HashStable<StableHashingContext<'gcx>> for ty::BoundTyIndex {
|
||||
impl<'gcx> HashStable<StableHashingContext<'gcx>> for ty::BoundVar {
|
||||
#[inline]
|
||||
fn hash_stable<W: StableHasherResult>(&self,
|
||||
hcx: &mut StableHashingContext<'gcx>,
|
||||
|
@ -23,7 +23,7 @@ use infer::InferCtxt;
|
||||
use std::sync::atomic::Ordering;
|
||||
use ty::fold::{TypeFoldable, TypeFolder};
|
||||
use ty::subst::Kind;
|
||||
use ty::{self, BoundTy, BoundTyIndex, Lift, List, Ty, TyCtxt, TypeFlags};
|
||||
use ty::{self, BoundTy, BoundVar, Lift, List, Ty, TyCtxt, TypeFlags};
|
||||
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_data_structures::indexed_vec::Idx;
|
||||
@ -277,7 +277,7 @@ struct Canonicalizer<'cx, 'gcx: 'tcx, 'tcx: 'cx> {
|
||||
query_state: &'cx mut OriginalQueryValues<'tcx>,
|
||||
// Note that indices is only used once `var_values` is big enough to be
|
||||
// heap-allocated.
|
||||
indices: FxHashMap<Kind<'tcx>, BoundTyIndex>,
|
||||
indices: FxHashMap<Kind<'tcx>, BoundVar>,
|
||||
canonicalize_region_mode: &'cx dyn CanonicalizeRegionMode,
|
||||
needs_canonical_flags: TypeFlags,
|
||||
}
|
||||
@ -455,7 +455,7 @@ impl<'cx, 'gcx, 'tcx> Canonicalizer<'cx, 'gcx, 'tcx> {
|
||||
/// or returns an existing variable if `kind` has already been
|
||||
/// seen. `kind` is expected to be an unbound variable (or
|
||||
/// potentially a free region).
|
||||
fn canonical_var(&mut self, info: CanonicalVarInfo, kind: Kind<'tcx>) -> BoundTyIndex {
|
||||
fn canonical_var(&mut self, info: CanonicalVarInfo, kind: Kind<'tcx>) -> BoundVar {
|
||||
let Canonicalizer {
|
||||
variables,
|
||||
query_state,
|
||||
@ -475,7 +475,7 @@ impl<'cx, 'gcx, 'tcx> Canonicalizer<'cx, 'gcx, 'tcx> {
|
||||
// direct linear search of `var_values`.
|
||||
if let Some(idx) = var_values.iter().position(|&k| k == kind) {
|
||||
// `kind` is already present in `var_values`.
|
||||
BoundTyIndex::new(idx)
|
||||
BoundVar::new(idx)
|
||||
} else {
|
||||
// `kind` isn't present in `var_values`. Append it. Likewise
|
||||
// for `info` and `variables`.
|
||||
@ -490,11 +490,11 @@ impl<'cx, 'gcx, 'tcx> Canonicalizer<'cx, 'gcx, 'tcx> {
|
||||
*indices = var_values
|
||||
.iter()
|
||||
.enumerate()
|
||||
.map(|(i, &kind)| (kind, BoundTyIndex::new(i)))
|
||||
.map(|(i, &kind)| (kind, BoundVar::new(i)))
|
||||
.collect();
|
||||
}
|
||||
// The cv is the index of the appended element.
|
||||
BoundTyIndex::new(var_values.len() - 1)
|
||||
BoundVar::new(var_values.len() - 1)
|
||||
}
|
||||
} else {
|
||||
// `var_values` is large. Do a hashmap search via `indices`.
|
||||
@ -502,7 +502,7 @@ impl<'cx, 'gcx, 'tcx> Canonicalizer<'cx, 'gcx, 'tcx> {
|
||||
variables.push(info);
|
||||
var_values.push(kind);
|
||||
assert_eq!(variables.len(), var_values.len());
|
||||
BoundTyIndex::new(variables.len() - 1)
|
||||
BoundVar::new(variables.len() - 1)
|
||||
})
|
||||
};
|
||||
|
||||
|
@ -40,7 +40,7 @@ use std::ops::Index;
|
||||
use syntax::source_map::Span;
|
||||
use ty::fold::TypeFoldable;
|
||||
use ty::subst::Kind;
|
||||
use ty::{self, BoundTyIndex, Lift, List, Region, TyCtxt};
|
||||
use ty::{self, BoundVar, Lift, List, Region, TyCtxt};
|
||||
|
||||
mod canonicalizer;
|
||||
|
||||
@ -73,7 +73,7 @@ impl<'gcx> UseSpecializedDecodable for CanonicalVarInfos<'gcx> {}
|
||||
/// canonicalized query response.
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Hash, RustcDecodable, RustcEncodable)]
|
||||
pub struct CanonicalVarValues<'tcx> {
|
||||
pub var_values: IndexVec<BoundTyIndex, Kind<'tcx>>,
|
||||
pub var_values: IndexVec<BoundVar, Kind<'tcx>>,
|
||||
}
|
||||
|
||||
/// 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> {
|
||||
variables: &List<CanonicalVarInfo>,
|
||||
universe_map: impl Fn(ty::UniverseIndex) -> ty::UniverseIndex,
|
||||
) -> CanonicalVarValues<'tcx> {
|
||||
let var_values: IndexVec<BoundTyIndex, Kind<'tcx>> = variables
|
||||
let var_values: IndexVec<BoundVar, Kind<'tcx>> = variables
|
||||
.iter()
|
||||
.map(|info| self.instantiate_canonical_var(span, *info, &universe_map))
|
||||
.collect();
|
||||
@ -456,10 +456,10 @@ BraceStructLiftImpl! {
|
||||
} where R: Lift<'tcx>
|
||||
}
|
||||
|
||||
impl<'tcx> Index<BoundTyIndex> for CanonicalVarValues<'tcx> {
|
||||
impl<'tcx> Index<BoundVar> for CanonicalVarValues<'tcx> {
|
||||
type Output = Kind<'tcx>;
|
||||
|
||||
fn index(&self, value: BoundTyIndex) -> &Kind<'tcx> {
|
||||
fn index(&self, value: BoundVar) -> &Kind<'tcx> {
|
||||
&self.var_values[value]
|
||||
}
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ use traits::{FulfillmentContext, TraitEngine};
|
||||
use traits::{Obligation, ObligationCause, PredicateObligation};
|
||||
use ty::fold::TypeFoldable;
|
||||
use ty::subst::{Kind, UnpackedKind};
|
||||
use ty::{self, BoundTyIndex, Lift, Ty, TyCtxt};
|
||||
use ty::{self, BoundVar, Lift, Ty, TyCtxt};
|
||||
|
||||
impl<'cx, 'gcx, 'tcx> InferCtxtBuilder<'cx, 'gcx, 'tcx> {
|
||||
/// The "main method" for a canonicalized trait query. Given the
|
||||
@ -273,7 +273,7 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {
|
||||
for (index, original_value) in original_values.var_values.iter().enumerate() {
|
||||
// ...with the value `v_r` of that variable from the query.
|
||||
let result_value = query_response.substitute_projected(self.tcx, &result_subst, |v| {
|
||||
&v.var_values[BoundTyIndex::new(index)]
|
||||
&v.var_values[BoundVar::new(index)]
|
||||
});
|
||||
match (original_value.unpack(), result_value.unpack()) {
|
||||
(UnpackedKind::Lifetime(ty::ReErased), UnpackedKind::Lifetime(ty::ReErased)) => {
|
||||
@ -423,7 +423,7 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {
|
||||
// is directly equal to one of the canonical variables in the
|
||||
// result, then we can type the corresponding value from the
|
||||
// input. See the example above.
|
||||
let mut opt_values: IndexVec<BoundTyIndex, Option<Kind<'tcx>>> =
|
||||
let mut opt_values: IndexVec<BoundVar, Option<Kind<'tcx>>> =
|
||||
IndexVec::from_elem_n(None, query_response.variables.len());
|
||||
|
||||
// In terms of our example above, we are iterating over pairs like:
|
||||
@ -457,7 +457,7 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {
|
||||
.enumerate()
|
||||
.map(|(index, info)| {
|
||||
if info.is_existential() {
|
||||
match opt_values[BoundTyIndex::new(index)] {
|
||||
match opt_values[BoundVar::new(index)] {
|
||||
Some(k) => k,
|
||||
None => self.instantiate_canonical_var(cause.span, *info, |u| {
|
||||
universe_map[u.as_usize()]
|
||||
@ -496,7 +496,7 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {
|
||||
// canonical variable; this is taken from
|
||||
// `query_response.var_values` after applying the substitution
|
||||
// `result_subst`.
|
||||
let substituted_query_response = |index: BoundTyIndex| -> Kind<'tcx> {
|
||||
let substituted_query_response = |index: BoundVar| -> Kind<'tcx> {
|
||||
query_response.substitute_projected(self.tcx, &result_subst, |v| &v.var_values[index])
|
||||
};
|
||||
|
||||
@ -552,12 +552,12 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {
|
||||
cause: &ObligationCause<'tcx>,
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
variables1: &OriginalQueryValues<'tcx>,
|
||||
variables2: impl Fn(BoundTyIndex) -> Kind<'tcx>,
|
||||
variables2: impl Fn(BoundVar) -> Kind<'tcx>,
|
||||
) -> InferResult<'tcx, ()> {
|
||||
self.commit_if_ok(|_| {
|
||||
let mut obligations = vec![];
|
||||
for (index, value1) in variables1.var_values.iter().enumerate() {
|
||||
let value2 = variables2(BoundTyIndex::new(index));
|
||||
let value2 = variables2(BoundVar::new(index));
|
||||
|
||||
match (value1.unpack(), value2.unpack()) {
|
||||
(UnpackedKind::Type(v1), UnpackedKind::Type(v2)) => {
|
||||
|
@ -63,7 +63,7 @@ use rustc_data_structures::stable_hasher::{StableHasher, StableHasherResult,
|
||||
|
||||
use hir;
|
||||
|
||||
pub use self::sty::{Binder, BoundTy, BoundTyKind, BoundTyIndex, DebruijnIndex, INNERMOST};
|
||||
pub use self::sty::{Binder, BoundTy, BoundTyKind, BoundVar, DebruijnIndex, INNERMOST};
|
||||
pub use self::sty::{FnSig, GenSig, CanonicalPolyFnSig, PolyFnSig, PolyGenSig};
|
||||
pub use self::sty::{InferTy, ParamTy, ProjectionTy, ExistentialPredicate};
|
||||
pub use self::sty::{ClosureSubsts, GeneratorSubsts, UpvarSubsts, TypeAndMut};
|
||||
|
@ -1171,7 +1171,7 @@ pub enum RegionKind {
|
||||
ReClosureBound(RegionVid),
|
||||
|
||||
/// Canonicalized region, used only when preparing a trait query.
|
||||
ReCanonical(BoundTyIndex),
|
||||
ReCanonical(BoundVar),
|
||||
}
|
||||
|
||||
impl<'tcx> serialize::UseSpecializedDecodable for Region<'tcx> {}
|
||||
@ -1225,13 +1225,13 @@ pub enum InferTy {
|
||||
}
|
||||
|
||||
newtype_index! {
|
||||
pub struct BoundTyIndex { .. }
|
||||
pub struct BoundVar { .. }
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, RustcEncodable, RustcDecodable)]
|
||||
pub struct BoundTy {
|
||||
pub level: DebruijnIndex,
|
||||
pub var: BoundTyIndex,
|
||||
pub var: BoundVar,
|
||||
pub kind: BoundTyKind,
|
||||
}
|
||||
|
||||
@ -1245,7 +1245,7 @@ impl_stable_hash_for!(struct BoundTy { level, var, kind });
|
||||
impl_stable_hash_for!(enum self::BoundTyKind { Anon, Param(a) });
|
||||
|
||||
impl BoundTy {
|
||||
pub fn new(level: DebruijnIndex, var: BoundTyIndex) -> Self {
|
||||
pub fn new(level: DebruijnIndex, var: BoundVar) -> Self {
|
||||
BoundTy {
|
||||
level,
|
||||
var,
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
use hir::def_id::DefId;
|
||||
use infer::canonical::Canonical;
|
||||
use ty::{self, BoundTyIndex, Lift, List, Ty, TyCtxt};
|
||||
use ty::{self, BoundVar, Lift, List, Ty, TyCtxt};
|
||||
use ty::fold::{TypeFoldable, TypeFolder, TypeVisitor};
|
||||
|
||||
use serialize::{self, Encodable, Encoder, Decodable, Decoder};
|
||||
@ -553,7 +553,7 @@ impl CanonicalUserSubsts<'tcx> {
|
||||
return false;
|
||||
}
|
||||
|
||||
self.value.substs.iter().zip(BoundTyIndex::new(0)..).all(|(kind, cvar)| {
|
||||
self.value.substs.iter().zip(BoundVar::new(0)..).all(|(kind, cvar)| {
|
||||
match kind.unpack() {
|
||||
UnpackedKind::Type(ty) => match ty.sty {
|
||||
ty::Bound(ref b) => cvar == b.var,
|
||||
|
Loading…
Reference in New Issue
Block a user