]> git.lizzy.rs Git - rust.git/commitdiff
Rename CanonicalVar to BoundTyIndex
authorFabian Drinck <fabian.drinck@rwth-aachen.de>
Sat, 20 Oct 2018 16:39:29 +0000 (18:39 +0200)
committerFabian Drinck <fabian.drinck@rwth-aachen.de>
Sat, 20 Oct 2018 16:39:29 +0000 (18:39 +0200)
src/librustc/ich/impls_ty.rs
src/librustc/infer/canonical/canonicalizer.rs
src/librustc/infer/canonical/mod.rs
src/librustc/infer/canonical/query_response.rs
src/librustc/ty/mod.rs
src/librustc/ty/sty.rs
src/librustc/ty/subst.rs

index 2a3d40c0e3fc1f94abf719f60b12d62f1f537225..919d5749bbff07b55a8b17dfb2511564bf6d3c93 100644 (file)
@@ -147,7 +147,7 @@ fn hash_stable<W: StableHasherResult>(&self,
     }
 }
 
-impl<'gcx> HashStable<StableHashingContext<'gcx>> for ty::CanonicalVar {
+impl<'gcx> HashStable<StableHashingContext<'gcx>> for ty::BoundTyIndex {
     #[inline]
     fn hash_stable<W: StableHasherResult>(&self,
                                           hcx: &mut StableHashingContext<'gcx>,
index 8c87c2a01c04fff99a3fe16ccc06ac3a71dfc5e9..46e32f2374cc590298353a9efe8bae73aee37ba2 100644 (file)
@@ -23,7 +23,7 @@
 use std::sync::atomic::Ordering;
 use ty::fold::{TypeFoldable, TypeFolder};
 use ty::subst::Kind;
-use ty::{self, CanonicalVar, Lift, List, Ty, TyCtxt, TypeFlags};
+use ty::{self, BoundTyIndex, Lift, List, Ty, TyCtxt, TypeFlags};
 
 use rustc_data_structures::fx::FxHashMap;
 use rustc_data_structures::indexed_vec::Idx;
@@ -225,7 +225,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>, CanonicalVar>,
+    indices: FxHashMap<Kind<'tcx>, BoundTyIndex>,
     canonicalize_region_mode: &'cx dyn CanonicalizeRegionMode,
     needs_canonical_flags: TypeFlags,
 }
@@ -393,7 +393,7 @@ fn canonicalize<V>(
     /// 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>) -> CanonicalVar {
+    fn canonical_var(&mut self, info: CanonicalVarInfo, kind: Kind<'tcx>) -> BoundTyIndex {
         let Canonicalizer {
             variables,
             query_state,
@@ -413,7 +413,7 @@ fn canonical_var(&mut self, info: CanonicalVarInfo, kind: Kind<'tcx>) -> Canonic
             // direct linear search of `var_values`.
             if let Some(idx) = var_values.iter().position(|&k| k == kind) {
                 // `kind` is already present in `var_values`.
-                CanonicalVar::new(idx)
+                BoundTyIndex::new(idx)
             } else {
                 // `kind` isn't present in `var_values`. Append it. Likewise
                 // for `info` and `variables`.
@@ -428,11 +428,11 @@ fn canonical_var(&mut self, info: CanonicalVarInfo, kind: Kind<'tcx>) -> Canonic
                     *indices = var_values
                         .iter()
                         .enumerate()
-                        .map(|(i, &kind)| (kind, CanonicalVar::new(i)))
+                        .map(|(i, &kind)| (kind, BoundTyIndex::new(i)))
                         .collect();
                 }
                 // The cv is the index of the appended element.
-                CanonicalVar::new(var_values.len() - 1)
+                BoundTyIndex::new(var_values.len() - 1)
             }
         } else {
             // `var_values` is large. Do a hashmap search via `indices`.
@@ -440,7 +440,7 @@ fn canonical_var(&mut self, info: CanonicalVarInfo, kind: Kind<'tcx>) -> Canonic
                 variables.push(info);
                 var_values.push(kind);
                 assert_eq!(variables.len(), var_values.len());
-                CanonicalVar::new(variables.len() - 1)
+                BoundTyIndex::new(variables.len() - 1)
             })
         }
     }
index 1863f08930f5f55b04b1f24fd13ff6b3ecc0c375..e3bd407d17a90785a27ff6da5fc02dbda78211ed 100644 (file)
@@ -40,7 +40,7 @@
 use syntax::source_map::Span;
 use ty::fold::TypeFoldable;
 use ty::subst::Kind;
-use ty::{self, CanonicalVar, Lift, Region, List, TyCtxt};
+use ty::{self, BoundTyIndex, Lift, Region, List, TyCtxt};
 
 mod canonicalizer;
 
@@ -72,7 +72,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<CanonicalVar, Kind<'tcx>>,
+    pub var_values: IndexVec<BoundTyIndex, Kind<'tcx>>,
 }
 
 /// When we canonicalize a value to form a query, we wind up replacing
@@ -264,7 +264,7 @@ fn fresh_inference_vars_for_canonical_vars(
         span: Span,
         variables: &List<CanonicalVarInfo>,
     ) -> CanonicalVarValues<'tcx> {
-        let var_values: IndexVec<CanonicalVar, Kind<'tcx>> = variables
+        let var_values: IndexVec<BoundTyIndex, Kind<'tcx>> = variables
             .iter()
             .map(|info| self.fresh_inference_var_for_canonical_var(span, *info))
             .collect();
@@ -367,10 +367,10 @@ impl<'a, 'tcx, R> Lift<'tcx> for QueryResponse<'a, R> {
     } where R: Lift<'tcx>
 }
 
-impl<'tcx> Index<CanonicalVar> for CanonicalVarValues<'tcx> {
+impl<'tcx> Index<BoundTyIndex> for CanonicalVarValues<'tcx> {
     type Output = Kind<'tcx>;
 
-    fn index(&self, value: CanonicalVar) -> &Kind<'tcx> {
+    fn index(&self, value: BoundTyIndex) -> &Kind<'tcx> {
         &self.var_values[value]
     }
 }
index b9edc9f51eaa890d8be3297b1784b42aa346662d..3d4dc36a9be53fac73633b68e0f612acd95e8d4b 100644 (file)
@@ -35,7 +35,7 @@
 use traits::{Obligation, ObligationCause, PredicateObligation};
 use ty::fold::TypeFoldable;
 use ty::subst::{Kind, UnpackedKind};
-use ty::{self, CanonicalVar, Lift, Ty, TyCtxt};
+use ty::{self, BoundTyIndex, 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<R>(
         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[CanonicalVar::new(index)]
+                &v.var_values[BoundTyIndex::new(index)]
             });
             match (original_value.unpack(), result_value.unpack()) {
                 (UnpackedKind::Lifetime(ty::ReErased), UnpackedKind::Lifetime(ty::ReErased)) => {
@@ -408,7 +408,7 @@ fn query_response_substitution_guess<R>(
         // 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<CanonicalVar, Option<Kind<'tcx>>> =
+        let mut opt_values: IndexVec<BoundTyIndex, Option<Kind<'tcx>>> =
             IndexVec::from_elem_n(None, query_response.variables.len());
 
         // In terms of our example above, we are iterating over pairs like:
@@ -440,7 +440,7 @@ fn query_response_substitution_guess<R>(
                 .variables
                 .iter()
                 .enumerate()
-                .map(|(index, info)| opt_values[CanonicalVar::new(index)].unwrap_or_else(||
+                .map(|(index, info)| opt_values[BoundTyIndex::new(index)].unwrap_or_else(||
                     self.fresh_inference_var_for_canonical_var(cause.span, *info)
                 ))
                 .collect(),
@@ -470,7 +470,7 @@ fn unify_query_response_substitution_guess<R>(
         // canonical variable; this is taken from
         // `query_response.var_values` after applying the substitution
         // `result_subst`.
-        let substituted_query_response = |index: CanonicalVar| -> Kind<'tcx> {
+        let substituted_query_response = |index: BoundTyIndex| -> Kind<'tcx> {
             query_response.substitute_projected(self.tcx, &result_subst, |v| &v.var_values[index])
         };
 
@@ -526,12 +526,12 @@ fn unify_canonical_vars(
         cause: &ObligationCause<'tcx>,
         param_env: ty::ParamEnv<'tcx>,
         variables1: &OriginalQueryValues<'tcx>,
-        variables2: impl Fn(CanonicalVar) -> Kind<'tcx>,
+        variables2: impl Fn(BoundTyIndex) -> Kind<'tcx>,
     ) -> InferResult<'tcx, ()> {
         self.commit_if_ok(|_| {
             let mut obligations = vec![];
             for (index, value1) in variables1.var_values.iter().enumerate() {
-                let value2 = variables2(CanonicalVar::new(index));
+                let value2 = variables2(BoundTyIndex::new(index));
 
                 match (value1.unpack(), value2.unpack()) {
                     (UnpackedKind::Type(v1), UnpackedKind::Type(v2)) => {
index 760114a58388540eade32b9c83add67797936bc1..122067517cafc1e7021ed221ffd5775b03480cba 100644 (file)
@@ -63,7 +63,7 @@
 
 use hir;
 
-pub use self::sty::{Binder, CanonicalVar, DebruijnIndex, INNERMOST};
+pub use self::sty::{Binder, BoundTyIndex, DebruijnIndex, INNERMOST};
 pub use self::sty::{FnSig, GenSig, PolyFnSig, PolyGenSig};
 pub use self::sty::{InferTy, ParamTy, ProjectionTy, ExistentialPredicate};
 pub use self::sty::{ClosureSubsts, GeneratorSubsts, UpvarSubsts, TypeAndMut};
index cc6e6b2861ecb8578cb48180132d475185793aa6..f22c2ad296574ac02820b1382ce9dfac3cf5cc84 100644 (file)
@@ -1165,7 +1165,7 @@ pub enum RegionKind {
     ReClosureBound(RegionVid),
 
     /// Canonicalized region, used only when preparing a trait query.
-    ReCanonical(CanonicalVar),
+    ReCanonical(BoundTyIndex),
 }
 
 impl<'tcx> serialize::UseSpecializedDecodable for Region<'tcx> {}
@@ -1218,11 +1218,11 @@ pub enum InferTy {
     FreshFloatTy(u32),
 
     /// Canonicalized type variable, used only when preparing a trait query.
-    CanonicalTy(CanonicalVar),
+    CanonicalTy(BoundTyIndex),
 }
 
 newtype_index! {
-    pub struct CanonicalVar { .. }
+    pub struct BoundTyIndex { .. }
 }
 
 /// A `ProjectionPredicate` for an `ExistentialTraitRef`.
index 64cfba7df6e7d4df3379bcedafd58acf72aaef4c..f578518145cc68980d5f993412398b5a7b432eed 100644 (file)
@@ -12,7 +12,7 @@
 
 use hir::def_id::DefId;
 use infer::canonical::Canonical;
-use ty::{self, CanonicalVar, Lift, List, Ty, TyCtxt};
+use ty::{self, BoundTyIndex, 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(CanonicalVar::new(0)..).all(|(kind, cvar)| {
+        self.value.substs.iter().zip(BoundTyIndex::new(0)..).all(|(kind, cvar)| {
             match kind.unpack() {
                 UnpackedKind::Type(ty) => match ty.sty {
                     ty::Infer(ty::CanonicalTy(cvar1)) => cvar == cvar1,