From 3dd303aa894e65219117b831f5c6284ec1077eae Mon Sep 17 00:00:00 2001 From: scalexm Date: Tue, 23 Oct 2018 13:42:23 +0200 Subject: [PATCH] Rename `BoundTyIndex` to `BoundVar` --- src/librustc/ich/impls_ty.rs | 2 +- src/librustc/infer/canonical/canonicalizer.rs | 14 +++++++------- src/librustc/infer/canonical/mod.rs | 10 +++++----- src/librustc/infer/canonical/query_response.rs | 14 +++++++------- src/librustc/ty/mod.rs | 2 +- src/librustc/ty/sty.rs | 8 ++++---- src/librustc/ty/subst.rs | 4 ++-- 7 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/librustc/ich/impls_ty.rs b/src/librustc/ich/impls_ty.rs index 5873dd2eab7..c950942ee34 100644 --- a/src/librustc/ich/impls_ty.rs +++ b/src/librustc/ich/impls_ty.rs @@ -147,7 +147,7 @@ fn hash_stable(&self, } } -impl<'gcx> HashStable> for ty::BoundTyIndex { +impl<'gcx> HashStable> for ty::BoundVar { #[inline] fn hash_stable(&self, hcx: &mut StableHashingContext<'gcx>, diff --git a/src/librustc/infer/canonical/canonicalizer.rs b/src/librustc/infer/canonical/canonicalizer.rs index a7634b8bd2a..5a9887e4af4 100644 --- a/src/librustc/infer/canonical/canonicalizer.rs +++ b/src/librustc/infer/canonical/canonicalizer.rs @@ -23,7 +23,7 @@ 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, BoundTyIndex>, + indices: FxHashMap, BoundVar>, canonicalize_region_mode: &'cx dyn CanonicalizeRegionMode, needs_canonical_flags: TypeFlags, } @@ -455,7 +455,7 @@ fn canonicalize( /// 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 @@ fn canonical_var(&mut self, info: CanonicalVarInfo, kind: Kind<'tcx>) -> BoundTy // 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 @@ fn canonical_var(&mut self, info: CanonicalVarInfo, kind: Kind<'tcx>) -> BoundTy *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 @@ fn canonical_var(&mut self, info: CanonicalVarInfo, kind: Kind<'tcx>) -> BoundTy variables.push(info); var_values.push(kind); assert_eq!(variables.len(), var_values.len()); - BoundTyIndex::new(variables.len() - 1) + BoundVar::new(variables.len() - 1) }) }; diff --git a/src/librustc/infer/canonical/mod.rs b/src/librustc/infer/canonical/mod.rs index f2b7c6e0d0d..b6f79414725 100644 --- a/src/librustc/infer/canonical/mod.rs +++ b/src/librustc/infer/canonical/mod.rs @@ -40,7 +40,7 @@ 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>, + pub var_values: IndexVec>, } /// When we canonicalize a value to form a query, we wind up replacing @@ -337,7 +337,7 @@ fn instantiate_canonical_vars( variables: &List, universe_map: impl Fn(ty::UniverseIndex) -> ty::UniverseIndex, ) -> CanonicalVarValues<'tcx> { - let var_values: IndexVec> = variables + let var_values: IndexVec> = variables .iter() .map(|info| self.instantiate_canonical_var(span, *info, &universe_map)) .collect(); @@ -456,10 +456,10 @@ impl<'a, 'tcx, R> Lift<'tcx> for QueryResponse<'a, R> { } where R: Lift<'tcx> } -impl<'tcx> Index for CanonicalVarValues<'tcx> { +impl<'tcx> Index 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] } } diff --git a/src/librustc/infer/canonical/query_response.rs b/src/librustc/infer/canonical/query_response.rs index 27ee33a452e..6e17eabdbb7 100644 --- a/src/librustc/infer/canonical/query_response.rs +++ b/src/librustc/infer/canonical/query_response.rs @@ -35,7 +35,7 @@ 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 @@ pub fn instantiate_nll_query_response_and_region_obligations( 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 @@ fn query_response_substitution_guess( // 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>> = + let mut opt_values: IndexVec>> = 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 @@ fn query_response_substitution_guess( .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 @@ fn unify_query_response_substitution_guess( // 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 @@ fn unify_canonical_vars( 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)) => { diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index 6ce65177442..d2ef5d0b66a 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -63,7 +63,7 @@ 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}; diff --git a/src/librustc/ty/sty.rs b/src/librustc/ty/sty.rs index e812486d1f8..1890006b514 100644 --- a/src/librustc/ty/sty.rs +++ b/src/librustc/ty/sty.rs @@ -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 @@ pub enum BoundTyKind { 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, diff --git a/src/librustc/ty/subst.rs b/src/librustc/ty/subst.rs index 9e85cfe7a12..fd26b263efb 100644 --- a/src/librustc/ty/subst.rs +++ b/src/librustc/ty/subst.rs @@ -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 @@ pub fn is_identity(&self) -> bool { 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, -- GitLab