From 87c7e5702021542f4b73b49f6023b33d1f0ef2eb Mon Sep 17 00:00:00 2001 From: varkor Date: Wed, 22 Aug 2018 00:35:01 +0100 Subject: [PATCH] Rename ty::Slice to ty::List --- src/librustc/ich/impls_ty.rs | 4 +- src/librustc/infer/canonical/canonicalizer.rs | 4 +- src/librustc/infer/canonical/mod.rs | 6 +- src/librustc/traits/mod.rs | 6 +- src/librustc/traits/structural_impls.rs | 4 +- src/librustc/ty/codec.rs | 12 +- src/librustc/ty/context.rs | 120 +++++++++--------- src/librustc/ty/error.rs | 2 +- src/librustc/ty/mod.rs | 61 ++++----- src/librustc/ty/relate.rs | 4 +- src/librustc/ty/structural_impls.rs | 6 +- src/librustc/ty/sty.rs | 18 +-- src/librustc/ty/subst.rs | 4 +- src/librustc/ty/wf.rs | 4 +- src/librustc/util/ppaux.rs | 6 +- .../borrow_check/nll/type_check/relate_tys.rs | 4 +- .../borrow_check/nll/universal_regions.rs | 2 +- src/librustc_mir/transform/lower_128bit.rs | 4 +- src/librustc_traits/lowering.rs | 6 +- src/librustc_typeck/astconv.rs | 2 +- 20 files changed, 140 insertions(+), 139 deletions(-) diff --git a/src/librustc/ich/impls_ty.rs b/src/librustc/ich/impls_ty.rs index 46f4ed4ec47..a64d8c2967f 100644 --- a/src/librustc/ich/impls_ty.rs +++ b/src/librustc/ich/impls_ty.rs @@ -25,7 +25,7 @@ use ty; use mir; impl<'a, 'gcx, T> HashStable> -for &'gcx ty::Slice +for &'gcx ty::List where T: HashStable> { fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, @@ -53,7 +53,7 @@ for &'gcx ty::Slice } } -impl<'a, 'gcx, T> ToStableHashKey> for &'gcx ty::Slice +impl<'a, 'gcx, T> ToStableHashKey> for &'gcx ty::List where T: HashStable> { type KeyType = Fingerprint; diff --git a/src/librustc/infer/canonical/canonicalizer.rs b/src/librustc/infer/canonical/canonicalizer.rs index c4de95c60bf..7d5b0a8de8b 100644 --- a/src/librustc/infer/canonical/canonicalizer.rs +++ b/src/librustc/infer/canonical/canonicalizer.rs @@ -23,7 +23,7 @@ use infer::InferCtxt; use std::sync::atomic::Ordering; use ty::fold::{TypeFoldable, TypeFolder}; use ty::subst::Kind; -use ty::{self, CanonicalVar, Lift, Slice, Ty, TyCtxt, TypeFlags}; +use ty::{self, CanonicalVar, Lift, List, Ty, TyCtxt, TypeFlags}; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::indexed_vec::Idx; @@ -327,7 +327,7 @@ impl<'cx, 'gcx, 'tcx> Canonicalizer<'cx, 'gcx, 'tcx> { if !value.has_type_flags(needs_canonical_flags) { let out_value = gcx.lift(value).unwrap(); let canon_value = Canonical { - variables: Slice::empty(), + variables: List::empty(), value: out_value, }; return canon_value; diff --git a/src/librustc/infer/canonical/mod.rs b/src/librustc/infer/canonical/mod.rs index b56da8f6304..cb1e39bb9f7 100644 --- a/src/librustc/infer/canonical/mod.rs +++ b/src/librustc/infer/canonical/mod.rs @@ -40,7 +40,7 @@ use std::ops::Index; use syntax::source_map::Span; use ty::fold::TypeFoldable; use ty::subst::Kind; -use ty::{self, CanonicalVar, Lift, Region, Slice, TyCtxt}; +use ty::{self, CanonicalVar, Lift, Region, List, TyCtxt}; mod canonicalizer; @@ -57,7 +57,7 @@ pub struct Canonical<'gcx, V> { pub value: V, } -pub type CanonicalVarInfos<'gcx> = &'gcx Slice; +pub type CanonicalVarInfos<'gcx> = &'gcx List; impl<'gcx> UseSpecializedDecodable for CanonicalVarInfos<'gcx> {} @@ -221,7 +221,7 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> { fn fresh_inference_vars_for_canonical_vars( &self, span: Span, - variables: &Slice, + variables: &List, ) -> CanonicalVarValues<'tcx> { let var_values: IndexVec> = variables .iter() diff --git a/src/librustc/traits/mod.rs b/src/librustc/traits/mod.rs index 0ba94b5275c..e2dbe883540 100644 --- a/src/librustc/traits/mod.rs +++ b/src/librustc/traits/mod.rs @@ -24,7 +24,7 @@ use infer::outlives::env::OutlivesEnvironment; use middle::region; use mir::interpret::ConstEvalErr; use ty::subst::Substs; -use ty::{self, AdtKind, Slice, Ty, TyCtxt, GenericParamDefKind, ToPredicate}; +use ty::{self, AdtKind, List, Ty, TyCtxt, GenericParamDefKind, ToPredicate}; use ty::error::{ExpectedFound, TypeError}; use ty::fold::{TypeFolder, TypeFoldable, TypeVisitor}; use infer::{InferCtxt}; @@ -325,7 +325,7 @@ pub enum Goal<'tcx> { CannotProve, } -pub type Goals<'tcx> = &'tcx Slice>; +pub type Goals<'tcx> = &'tcx List>; impl<'tcx> DomainGoal<'tcx> { pub fn into_goal(self) -> Goal<'tcx> { @@ -357,7 +357,7 @@ pub enum Clause<'tcx> { } /// Multiple clauses. -pub type Clauses<'tcx> = &'tcx Slice>; +pub type Clauses<'tcx> = &'tcx List>; /// A "program clause" has the form `D :- G1, ..., Gn`. It is saying /// that the domain goal `D` is true if `G1...Gn` are provable. This diff --git a/src/librustc/traits/structural_impls.rs b/src/librustc/traits/structural_impls.rs index 9292b42eb52..87535a6ae8d 100644 --- a/src/librustc/traits/structural_impls.rs +++ b/src/librustc/traits/structural_impls.rs @@ -620,7 +620,7 @@ EnumLiftImpl! { } } -impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::Slice> { +impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::List> { fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { let v = self.iter() .map(|t| t.fold_with(folder)) @@ -658,7 +658,7 @@ EnumTypeFoldableImpl! { } } -impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::Slice> { +impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::List> { fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { let v = self.iter() .map(|t| t.fold_with(folder)) diff --git a/src/librustc/ty/codec.rs b/src/librustc/ty/codec.rs index 967a3324cfb..c343ded7657 100644 --- a/src/librustc/ty/codec.rs +++ b/src/librustc/ty/codec.rs @@ -212,7 +212,7 @@ pub fn decode_region<'a, 'tcx, D>(decoder: &mut D) -> Result, D #[inline] pub fn decode_ty_slice<'a, 'tcx, D>(decoder: &mut D) - -> Result<&'tcx ty::Slice>, D::Error> + -> Result<&'tcx ty::List>, D::Error> where D: TyDecoder<'a, 'tcx>, 'tcx: 'a, { @@ -232,7 +232,7 @@ pub fn decode_adt_def<'a, 'tcx, D>(decoder: &mut D) #[inline] pub fn decode_existential_predicate_slice<'a, 'tcx, D>(decoder: &mut D) - -> Result<&'tcx ty::Slice>, D::Error> + -> Result<&'tcx ty::List>, D::Error> where D: TyDecoder<'a, 'tcx>, 'tcx: 'a, { @@ -366,10 +366,10 @@ macro_rules! implement_ty_decoder { } } - impl<$($typaram),*> SpecializedDecoder<&'tcx ty::Slice>> + impl<$($typaram),*> SpecializedDecoder<&'tcx ty::List>> for $DecoderName<$($typaram),*> { fn specialized_decode(&mut self) - -> Result<&'tcx ty::Slice>, Self::Error> { + -> Result<&'tcx ty::List>, Self::Error> { decode_ty_slice(self) } } @@ -381,10 +381,10 @@ macro_rules! implement_ty_decoder { } } - impl<$($typaram),*> SpecializedDecoder<&'tcx ty::Slice>> + impl<$($typaram),*> SpecializedDecoder<&'tcx ty::List>> for $DecoderName<$($typaram),*> { fn specialized_decode(&mut self) - -> Result<&'tcx ty::Slice>, Self::Error> { + -> Result<&'tcx ty::List>, Self::Error> { decode_existential_predicate_slice(self) } } diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index ee0543f53ba..ba274236eb9 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -38,7 +38,7 @@ use ty::ReprOptions; use traits; use traits::{Clause, Clauses, Goal, Goals}; use ty::{self, Ty, TypeAndMut}; -use ty::{TyS, TypeVariants, Slice}; +use ty::{TyS, TypeVariants, List}; use ty::{AdtKind, AdtDef, ClosureSubsts, GeneratorSubsts, Region, Const}; use ty::{PolyFnSig, InferTy, ParamTy, ProjectionTy, ExistentialPredicate, Predicate}; use ty::RegionKind; @@ -135,15 +135,15 @@ pub struct CtxtInterners<'tcx> { /// Specifically use a speedy hash algorithm for these hash sets, /// they're accessed quite often. type_: InternedSet<'tcx, TyS<'tcx>>, - type_list: InternedSet<'tcx, Slice>>, + type_list: InternedSet<'tcx, List>>, substs: InternedSet<'tcx, Substs<'tcx>>, - canonical_var_infos: InternedSet<'tcx, Slice>, + canonical_var_infos: InternedSet<'tcx, List>, region: InternedSet<'tcx, RegionKind>, - existential_predicates: InternedSet<'tcx, Slice>>, - predicates: InternedSet<'tcx, Slice>>, + existential_predicates: InternedSet<'tcx, List>>, + predicates: InternedSet<'tcx, List>>, const_: InternedSet<'tcx, Const<'tcx>>, - clauses: InternedSet<'tcx, Slice>>, - goals: InternedSet<'tcx, Slice>>, + clauses: InternedSet<'tcx, List>>, + goals: InternedSet<'tcx, List>>, } impl<'gcx: 'tcx, 'tcx> CtxtInterners<'tcx> { @@ -1593,12 +1593,12 @@ impl<'a, 'tcx> Lift<'tcx> for &'a Goal<'a> { } } -impl<'a, 'tcx> Lift<'tcx> for &'a Slice> { - type Lifted = &'tcx Slice>; +impl<'a, 'tcx> Lift<'tcx> for &'a List> { + type Lifted = &'tcx List>; fn lift_to_tcx<'b, 'gcx>( &self, tcx: TyCtxt<'b, 'gcx, 'tcx>, - ) -> Option<&'tcx Slice>> { + ) -> Option<&'tcx List>> { if tcx.interners.arena.in_arena(*self as *const _) { return Some(unsafe { mem::transmute(*self) }); } @@ -1611,12 +1611,12 @@ impl<'a, 'tcx> Lift<'tcx> for &'a Slice> { } } -impl<'a, 'tcx> Lift<'tcx> for &'a Slice> { - type Lifted = &'tcx Slice>; +impl<'a, 'tcx> Lift<'tcx> for &'a List> { + type Lifted = &'tcx List>; fn lift_to_tcx<'b, 'gcx>( &self, tcx: TyCtxt<'b, 'gcx, 'tcx>, - ) -> Option<&'tcx Slice>> { + ) -> Option<&'tcx List>> { if tcx.interners.arena.in_arena(*self as *const _) { return Some(unsafe { mem::transmute(*self) }); } @@ -1648,7 +1648,7 @@ impl<'a, 'tcx> Lift<'tcx> for &'a Substs<'a> { type Lifted = &'tcx Substs<'tcx>; fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option<&'tcx Substs<'tcx>> { if self.len() == 0 { - return Some(Slice::empty()); + return Some(List::empty()); } if tcx.interners.arena.in_arena(&self[..] as *const _) { return Some(unsafe { mem::transmute(*self) }); @@ -1662,12 +1662,12 @@ impl<'a, 'tcx> Lift<'tcx> for &'a Substs<'a> { } } -impl<'a, 'tcx> Lift<'tcx> for &'a Slice> { - type Lifted = &'tcx Slice>; +impl<'a, 'tcx> Lift<'tcx> for &'a List> { + type Lifted = &'tcx List>; fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) - -> Option<&'tcx Slice>> { + -> Option<&'tcx List>> { if self.len() == 0 { - return Some(Slice::empty()); + return Some(List::empty()); } if tcx.interners.arena.in_arena(*self as *const _) { return Some(unsafe { mem::transmute(*self) }); @@ -1681,12 +1681,12 @@ impl<'a, 'tcx> Lift<'tcx> for &'a Slice> { } } -impl<'a, 'tcx> Lift<'tcx> for &'a Slice> { - type Lifted = &'tcx Slice>; +impl<'a, 'tcx> Lift<'tcx> for &'a List> { + type Lifted = &'tcx List>; fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) - -> Option<&'tcx Slice>> { + -> Option<&'tcx List>> { if self.is_empty() { - return Some(Slice::empty()); + return Some(List::empty()); } if tcx.interners.arena.in_arena(*self as *const _) { return Some(unsafe { mem::transmute(*self) }); @@ -1700,12 +1700,12 @@ impl<'a, 'tcx> Lift<'tcx> for &'a Slice> { } } -impl<'a, 'tcx> Lift<'tcx> for &'a Slice> { - type Lifted = &'tcx Slice>; +impl<'a, 'tcx> Lift<'tcx> for &'a List> { + type Lifted = &'tcx List>; fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) - -> Option<&'tcx Slice>> { + -> Option<&'tcx List>> { if self.is_empty() { - return Some(Slice::empty()); + return Some(List::empty()); } if tcx.interners.arena.in_arena(*self as *const _) { return Some(unsafe { mem::transmute(*self) }); @@ -1719,11 +1719,11 @@ impl<'a, 'tcx> Lift<'tcx> for &'a Slice> { } } -impl<'a, 'tcx> Lift<'tcx> for &'a Slice { - type Lifted = &'tcx Slice; +impl<'a, 'tcx> Lift<'tcx> for &'a List { + type Lifted = &'tcx List; fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option { if self.len() == 0 { - return Some(Slice::empty()); + return Some(List::empty()); } if tcx.interners.arena.in_arena(*self as *const _) { return Some(unsafe { mem::transmute(*self) }); @@ -2113,28 +2113,28 @@ impl<'tcx: 'lcx, 'lcx> Borrow> for Interned<'tcx, TyS<'tcx>> } } -// NB: An Interned> compares and hashes as its elements. -impl<'tcx, T: PartialEq> PartialEq for Interned<'tcx, Slice> { - fn eq(&self, other: &Interned<'tcx, Slice>) -> bool { +// NB: An Interned> compares and hashes as its elements. +impl<'tcx, T: PartialEq> PartialEq for Interned<'tcx, List> { + fn eq(&self, other: &Interned<'tcx, List>) -> bool { self.0[..] == other.0[..] } } -impl<'tcx, T: Eq> Eq for Interned<'tcx, Slice> {} +impl<'tcx, T: Eq> Eq for Interned<'tcx, List> {} -impl<'tcx, T: Hash> Hash for Interned<'tcx, Slice> { +impl<'tcx, T: Hash> Hash for Interned<'tcx, List> { fn hash(&self, s: &mut H) { self.0[..].hash(s) } } -impl<'tcx: 'lcx, 'lcx> Borrow<[Ty<'lcx>]> for Interned<'tcx, Slice>> { +impl<'tcx: 'lcx, 'lcx> Borrow<[Ty<'lcx>]> for Interned<'tcx, List>> { fn borrow<'a>(&'a self) -> &'a [Ty<'lcx>] { &self.0[..] } } -impl<'tcx: 'lcx, 'lcx> Borrow<[CanonicalVarInfo]> for Interned<'tcx, Slice> { +impl<'tcx: 'lcx, 'lcx> Borrow<[CanonicalVarInfo]> for Interned<'tcx, List> { fn borrow<'a>(&'a self) -> &'a [CanonicalVarInfo] { &self.0[..] } @@ -2153,14 +2153,14 @@ impl<'tcx> Borrow for Interned<'tcx, RegionKind> { } impl<'tcx: 'lcx, 'lcx> Borrow<[ExistentialPredicate<'lcx>]> - for Interned<'tcx, Slice>> { + for Interned<'tcx, List>> { fn borrow<'a>(&'a self) -> &'a [ExistentialPredicate<'lcx>] { &self.0[..] } } impl<'tcx: 'lcx, 'lcx> Borrow<[Predicate<'lcx>]> - for Interned<'tcx, Slice>> { + for Interned<'tcx, List>> { fn borrow<'a>(&'a self) -> &'a [Predicate<'lcx>] { &self.0[..] } @@ -2173,14 +2173,14 @@ impl<'tcx: 'lcx, 'lcx> Borrow> for Interned<'tcx, Const<'tcx>> { } impl<'tcx: 'lcx, 'lcx> Borrow<[Clause<'lcx>]> -for Interned<'tcx, Slice>> { +for Interned<'tcx, List>> { fn borrow<'a>(&'a self) -> &'a [Clause<'lcx>] { &self.0[..] } } impl<'tcx: 'lcx, 'lcx> Borrow<[Goal<'lcx>]> -for Interned<'tcx, Slice>> { +for Interned<'tcx, List>> { fn borrow<'a>(&'a self) -> &'a [Goal<'lcx>] { &self.0[..] } @@ -2274,9 +2274,9 @@ macro_rules! slice_interners { ($($field:ident: $method:ident($ty:ident)),+) => ( $(intern_method!( 'tcx, $field: $method( &[$ty<'tcx>], - |a, v| Slice::from_arena(a, v), + |a, v| List::from_arena(a, v), Deref::deref, - |xs: &[$ty]| xs.iter().any(keep_local)) -> Slice<$ty<'tcx>>);)+ + |xs: &[$ty]| xs.iter().any(keep_local)) -> List<$ty<'tcx>>);)+ ) } @@ -2298,10 +2298,10 @@ intern_method! { 'tcx, canonical_var_infos: _intern_canonical_var_infos( &[CanonicalVarInfo], - |a, v| Slice::from_arena(a, v), + |a, v| List::from_arena(a, v), Deref::deref, |_xs: &[CanonicalVarInfo]| -> bool { false } - ) -> Slice + ) -> List } impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { @@ -2480,7 +2480,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { pub fn mk_dynamic( self, - obj: ty::Binder<&'tcx Slice>>, + obj: ty::Binder<&'tcx List>>, reg: ty::Region<'tcx> ) -> Ty<'tcx> { self.mk_ty(TyDynamic(obj, reg)) @@ -2509,7 +2509,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { self.mk_ty(TyGenerator(id, generator_substs, movability)) } - pub fn mk_generator_witness(self, types: ty::Binder<&'tcx Slice>>) -> Ty<'tcx> { + pub fn mk_generator_witness(self, types: ty::Binder<&'tcx List>>) -> Ty<'tcx> { self.mk_ty(TyGeneratorWitness(types)) } @@ -2553,36 +2553,36 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { } pub fn intern_existential_predicates(self, eps: &[ExistentialPredicate<'tcx>]) - -> &'tcx Slice> { + -> &'tcx List> { assert!(!eps.is_empty()); assert!(eps.windows(2).all(|w| w[0].stable_cmp(self, &w[1]) != Ordering::Greater)); self._intern_existential_predicates(eps) } pub fn intern_predicates(self, preds: &[Predicate<'tcx>]) - -> &'tcx Slice> { + -> &'tcx List> { // FIXME consider asking the input slice to be sorted to avoid // re-interning permutations, in which case that would be asserted // here. if preds.len() == 0 { // The macro-generated method below asserts we don't intern an empty slice. - Slice::empty() + List::empty() } else { self._intern_predicates(preds) } } - pub fn intern_type_list(self, ts: &[Ty<'tcx>]) -> &'tcx Slice> { + pub fn intern_type_list(self, ts: &[Ty<'tcx>]) -> &'tcx List> { if ts.len() == 0 { - Slice::empty() + List::empty() } else { self._intern_type_list(ts) } } - pub fn intern_substs(self, ts: &[Kind<'tcx>]) -> &'tcx Slice> { + pub fn intern_substs(self, ts: &[Kind<'tcx>]) -> &'tcx List> { if ts.len() == 0 { - Slice::empty() + List::empty() } else { self._intern_substs(ts) } @@ -2590,7 +2590,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { pub fn intern_canonical_var_infos(self, ts: &[CanonicalVarInfo]) -> CanonicalVarInfos<'gcx> { if ts.len() == 0 { - Slice::empty() + List::empty() } else { self.global_tcx()._intern_canonical_var_infos(ts) } @@ -2598,7 +2598,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { pub fn intern_clauses(self, ts: &[Clause<'tcx>]) -> Clauses<'tcx> { if ts.len() == 0 { - Slice::empty() + List::empty() } else { self._intern_clauses(ts) } @@ -2606,7 +2606,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { pub fn intern_goals(self, ts: &[Goal<'tcx>]) -> Goals<'tcx> { if ts.len() == 0 { - Slice::empty() + List::empty() } else { self._intern_goals(ts) } @@ -2629,24 +2629,24 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { } pub fn mk_existential_predicates], - &'tcx Slice>>>(self, iter: I) + &'tcx List>>>(self, iter: I) -> I::Output { iter.intern_with(|xs| self.intern_existential_predicates(xs)) } pub fn mk_predicates], - &'tcx Slice>>>(self, iter: I) + &'tcx List>>>(self, iter: I) -> I::Output { iter.intern_with(|xs| self.intern_predicates(xs)) } pub fn mk_type_list], - &'tcx Slice>>>(self, iter: I) -> I::Output { + &'tcx List>>>(self, iter: I) -> I::Output { iter.intern_with(|xs| self.intern_type_list(xs)) } pub fn mk_substs], - &'tcx Slice>>>(self, iter: I) -> I::Output { + &'tcx List>>>(self, iter: I) -> I::Output { iter.intern_with(|xs| self.intern_substs(xs)) } diff --git a/src/librustc/ty/error.rs b/src/librustc/ty/error.rs index e23034bde76..5ba697ee795 100644 --- a/src/librustc/ty/error.rs +++ b/src/librustc/ty/error.rs @@ -51,7 +51,7 @@ pub enum TypeError<'tcx> { CyclicTy(Ty<'tcx>), ProjectionMismatched(ExpectedFound), ProjectionBoundsLength(ExpectedFound), - ExistentialMismatch(ExpectedFound<&'tcx ty::Slice>>), + ExistentialMismatch(ExpectedFound<&'tcx ty::List>>), OldStyleLUB(Box>), } diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index 486ed85843c..46fbedb5a26 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -596,8 +596,8 @@ impl<'tcx> serialize::UseSpecializedDecodable for Ty<'tcx> {} pub type CanonicalTy<'gcx> = Canonical<'gcx, Ty<'gcx>>; extern { - /// A dummy type used to force Slice to by unsized without requiring fat pointers - type OpaqueSliceContents; + /// A dummy type used to force List to by unsized without requiring fat pointers + type OpaqueListContents; } /// A wrapper for slices with the additional invariant @@ -605,18 +605,19 @@ extern { /// the same contents can exist in the same context. /// This means we can use pointer for both /// equality comparisons and hashing. +/// Note: `Slice` was already taken by the `Ty`. #[repr(C)] -pub struct Slice { +pub struct List { len: usize, data: [T; 0], - opaque: OpaqueSliceContents, + opaque: OpaqueListContents, } -unsafe impl Sync for Slice {} +unsafe impl Sync for List {} -impl Slice { +impl List { #[inline] - fn from_arena<'tcx>(arena: &'tcx SyncDroplessArena, slice: &[T]) -> &'tcx Slice { + fn from_arena<'tcx>(arena: &'tcx SyncDroplessArena, slice: &[T]) -> &'tcx List { assert!(!mem::needs_drop::()); assert!(mem::size_of::() != 0); assert!(slice.len() != 0); @@ -633,7 +634,7 @@ impl Slice { size, cmp::max(mem::align_of::(), mem::align_of::())); unsafe { - let result = &mut *(mem.as_mut_ptr() as *mut Slice); + let result = &mut *(mem.as_mut_ptr() as *mut List); // Write the length result.len = slice.len(); @@ -646,51 +647,51 @@ impl Slice { } } -impl fmt::Debug for Slice { +impl fmt::Debug for List { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { (**self).fmt(f) } } -impl Encodable for Slice { +impl Encodable for List { #[inline] fn encode(&self, s: &mut S) -> Result<(), S::Error> { (**self).encode(s) } } -impl Ord for Slice where T: Ord { - fn cmp(&self, other: &Slice) -> Ordering { +impl Ord for List where T: Ord { + fn cmp(&self, other: &List) -> Ordering { if self == other { Ordering::Equal } else { <[T] as Ord>::cmp(&**self, &**other) } } } -impl PartialOrd for Slice where T: PartialOrd { - fn partial_cmp(&self, other: &Slice) -> Option { +impl PartialOrd for List where T: PartialOrd { + fn partial_cmp(&self, other: &List) -> Option { if self == other { Some(Ordering::Equal) } else { <[T] as PartialOrd>::partial_cmp(&**self, &**other) } } } -impl PartialEq for Slice { +impl PartialEq for List { #[inline] - fn eq(&self, other: &Slice) -> bool { + fn eq(&self, other: &List) -> bool { ptr::eq(self, other) } } -impl Eq for Slice {} +impl Eq for List {} -impl Hash for Slice { +impl Hash for List { #[inline] fn hash(&self, s: &mut H) { - (self as *const Slice).hash(s) + (self as *const List).hash(s) } } -impl Deref for Slice { +impl Deref for List { type Target = [T]; #[inline(always)] fn deref(&self) -> &[T] { @@ -700,7 +701,7 @@ impl Deref for Slice { } } -impl<'a, T> IntoIterator for &'a Slice { +impl<'a, T> IntoIterator for &'a List { type Item = &'a T; type IntoIter = <&'a [T] as IntoIterator>::IntoIter; #[inline(always)] @@ -709,17 +710,17 @@ impl<'a, T> IntoIterator for &'a Slice { } } -impl<'tcx> serialize::UseSpecializedDecodable for &'tcx Slice> {} +impl<'tcx> serialize::UseSpecializedDecodable for &'tcx List> {} -impl Slice { +impl List { #[inline(always)] - pub fn empty<'a>() -> &'a Slice { + pub fn empty<'a>() -> &'a List { #[repr(align(64), C)] struct EmptySlice([u8; 64]); static EMPTY_SLICE: EmptySlice = EmptySlice([0; 64]); assert!(mem::align_of::() <= 64); unsafe { - &*(&EMPTY_SLICE as *const _ as *const Slice) + &*(&EMPTY_SLICE as *const _ as *const List) } } } @@ -1556,7 +1557,7 @@ pub struct ParamEnv<'tcx> { /// Obligations that the caller must satisfy. This is basically /// the set of bounds on the in-scope type parameters, translated /// into Obligations, and elaborated and normalized. - pub caller_bounds: &'tcx Slice>, + pub caller_bounds: &'tcx List>, /// Typically, this is `Reveal::UserFacing`, but during codegen we /// want `Reveal::All` -- note that this is always paired with an @@ -1570,7 +1571,7 @@ impl<'tcx> ParamEnv<'tcx> { /// Trait`) are left hidden, so this is suitable for ordinary /// type-checking. pub fn empty() -> Self { - Self::new(ty::Slice::empty(), Reveal::UserFacing) + Self::new(List::empty(), Reveal::UserFacing) } /// Construct a trait environment with no where clauses in scope @@ -1581,11 +1582,11 @@ impl<'tcx> ParamEnv<'tcx> { /// NB. If you want to have predicates in scope, use `ParamEnv::new`, /// or invoke `param_env.with_reveal_all()`. pub fn reveal_all() -> Self { - Self::new(ty::Slice::empty(), Reveal::All) + Self::new(List::empty(), Reveal::All) } /// Construct a trait environment with the given set of predicates. - pub fn new(caller_bounds: &'tcx ty::Slice>, + pub fn new(caller_bounds: &'tcx List>, reveal: Reveal) -> Self { ty::ParamEnv { caller_bounds, reveal } @@ -1603,7 +1604,7 @@ impl<'tcx> ParamEnv<'tcx> { /// Returns this same environment but with no caller bounds. pub fn without_caller_bounds(self) -> Self { - ty::ParamEnv { caller_bounds: ty::Slice::empty(), ..self } + ty::ParamEnv { caller_bounds: List::empty(), ..self } } /// Creates a suitable environment in which to perform trait diff --git a/src/librustc/ty/relate.rs b/src/librustc/ty/relate.rs index 4e8f33d6a4a..85f72203da8 100644 --- a/src/librustc/ty/relate.rs +++ b/src/librustc/ty/relate.rs @@ -316,7 +316,7 @@ impl<'tcx> Relate<'tcx> for ty::ExistentialTraitRef<'tcx> { } #[derive(Debug, Clone)] -struct GeneratorWitness<'tcx>(&'tcx ty::Slice>); +struct GeneratorWitness<'tcx>(&'tcx ty::List>); TupleStructTypeFoldableImpl! { impl<'tcx> TypeFoldable<'tcx> for GeneratorWitness<'tcx> { @@ -578,7 +578,7 @@ pub fn super_relate_tys<'a, 'gcx, 'tcx, R>(relation: &mut R, } } -impl<'tcx> Relate<'tcx> for &'tcx ty::Slice> { +impl<'tcx> Relate<'tcx> for &'tcx ty::List> { fn relate<'a, 'gcx, R>(relation: &mut R, a: &Self, b: &Self) diff --git a/src/librustc/ty/structural_impls.rs b/src/librustc/ty/structural_impls.rs index ad29f808285..9fad583050f 100644 --- a/src/librustc/ty/structural_impls.rs +++ b/src/librustc/ty/structural_impls.rs @@ -735,7 +735,7 @@ BraceStructTypeFoldableImpl! { impl<'tcx> TypeFoldable<'tcx> for ty::ParamEnv<'tcx> { reveal, caller_bounds } } -impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::Slice> { +impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::List> { fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { let v = self.iter().map(|p| p.fold_with(folder)).collect::>(); folder.tcx().intern_existential_predicates(&v) @@ -754,7 +754,7 @@ EnumTypeFoldableImpl! { } } -impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::Slice> { +impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::List> { fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { let v = self.iter().map(|t| t.fold_with(folder)).collect::>(); folder.tcx().intern_type_list(&v) @@ -1010,7 +1010,7 @@ BraceStructTypeFoldableImpl! { } } -impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::Slice> { +impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::List> { fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { let v = self.iter().map(|p| p.fold_with(folder)).collect::>(); folder.tcx().intern_predicates(&v) diff --git a/src/librustc/ty/sty.rs b/src/librustc/ty/sty.rs index 7c0857cd2f9..c0c435ae80a 100644 --- a/src/librustc/ty/sty.rs +++ b/src/librustc/ty/sty.rs @@ -18,7 +18,7 @@ use polonius_engine::Atom; use rustc_data_structures::indexed_vec::Idx; use ty::subst::{Substs, Subst, Kind, UnpackedKind}; use ty::{self, AdtDef, TypeFlags, Ty, TyCtxt, TypeFoldable}; -use ty::{Slice, TyS, ParamEnvAnd, ParamEnv}; +use ty::{List, TyS, ParamEnvAnd, ParamEnv}; use util::captures::Captures; use mir::interpret::{Scalar, Pointer}; @@ -133,7 +133,7 @@ pub enum TypeVariants<'tcx> { TyFnPtr(PolyFnSig<'tcx>), /// A trait, defined with `trait`. - TyDynamic(Binder<&'tcx Slice>>, ty::Region<'tcx>), + TyDynamic(Binder<&'tcx List>>, ty::Region<'tcx>), /// The anonymous type of a closure. Used to represent the type of /// `|a| a`. @@ -145,13 +145,13 @@ pub enum TypeVariants<'tcx> { /// A type representin the types stored inside a generator. /// This should only appear in GeneratorInteriors. - TyGeneratorWitness(Binder<&'tcx Slice>>), + TyGeneratorWitness(Binder<&'tcx List>>), /// The never type `!` TyNever, /// A tuple type. For example, `(i32, bool)`. - TyTuple(&'tcx Slice>), + TyTuple(&'tcx List>), /// The projection of an associated type. For example, /// `>::N`. @@ -536,9 +536,9 @@ impl<'a, 'gcx, 'tcx> Binder> { } } -impl<'tcx> serialize::UseSpecializedDecodable for &'tcx Slice> {} +impl<'tcx> serialize::UseSpecializedDecodable for &'tcx List> {} -impl<'tcx> Slice> { +impl<'tcx> List> { pub fn principal(&self) -> Option> { match self.get(0) { Some(&ExistentialPredicate::Trait(tr)) => Some(tr), @@ -568,7 +568,7 @@ impl<'tcx> Slice> { } } -impl<'tcx> Binder<&'tcx Slice>> { +impl<'tcx> Binder<&'tcx List>> { pub fn principal(&self) -> Option> { self.skip_binder().principal().map(Binder::bind) } @@ -918,7 +918,7 @@ impl<'tcx> PolyGenSig<'tcx> { /// - `variadic` indicates whether this is a variadic function. (only true for foreign fns) #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable)] pub struct FnSig<'tcx> { - pub inputs_and_output: &'tcx Slice>, + pub inputs_and_output: &'tcx List>, pub variadic: bool, pub unsafety: hir::Unsafety, pub abi: abi::Abi, @@ -943,7 +943,7 @@ impl<'tcx> PolyFnSig<'tcx> { pub fn input(&self, index: usize) -> ty::Binder> { self.map_bound_ref(|fn_sig| fn_sig.inputs()[index]) } - pub fn inputs_and_output(&self) -> ty::Binder<&'tcx Slice>> { + pub fn inputs_and_output(&self) -> ty::Binder<&'tcx List>> { self.map_bound_ref(|fn_sig| fn_sig.inputs_and_output) } pub fn output(&self) -> ty::Binder> { diff --git a/src/librustc/ty/subst.rs b/src/librustc/ty/subst.rs index a6ff979f472..f76411da458 100644 --- a/src/librustc/ty/subst.rs +++ b/src/librustc/ty/subst.rs @@ -11,7 +11,7 @@ // Type substitutions. use hir::def_id::DefId; -use ty::{self, Lift, Slice, Ty, TyCtxt}; +use ty::{self, Lift, List, Ty, TyCtxt}; use ty::fold::{TypeFoldable, TypeFolder, TypeVisitor}; use serialize::{self, Encodable, Encoder, Decodable, Decoder}; @@ -177,7 +177,7 @@ impl<'tcx> Decodable for Kind<'tcx> { } /// A substitution mapping generic parameters to new values. -pub type Substs<'tcx> = Slice>; +pub type Substs<'tcx> = List>; impl<'a, 'gcx, 'tcx> Substs<'tcx> { /// Creates a Substs that maps each generic parameter to itself. diff --git a/src/librustc/ty/wf.rs b/src/librustc/ty/wf.rs index b99cdd59773..d97553d6251 100644 --- a/src/librustc/ty/wf.rs +++ b/src/librustc/ty/wf.rs @@ -453,7 +453,7 @@ impl<'a, 'gcx, 'tcx> WfPredicates<'a, 'gcx, 'tcx> { } fn from_object_ty(&mut self, ty: Ty<'tcx>, - data: ty::Binder<&'tcx ty::Slice>>, + data: ty::Binder<&'tcx ty::List>>, region: ty::Region<'tcx>) { // Imagine a type like this: // @@ -513,7 +513,7 @@ impl<'a, 'gcx, 'tcx> WfPredicates<'a, 'gcx, 'tcx> { /// `ty::required_region_bounds`, see that for more information. pub fn object_region_bounds<'a, 'gcx, 'tcx>( tcx: TyCtxt<'a, 'gcx, 'tcx>, - existential_predicates: ty::Binder<&'tcx ty::Slice>>) + existential_predicates: ty::Binder<&'tcx ty::List>>) -> Vec> { // Since we don't actually *know* the self type for an object, diff --git a/src/librustc/util/ppaux.rs b/src/librustc/util/ppaux.rs index 9513086667b..964a65065bc 100644 --- a/src/librustc/util/ppaux.rs +++ b/src/librustc/util/ppaux.rs @@ -586,7 +586,7 @@ impl<'a, T: Print> Print for &'a T { } define_print! { - ('tcx) &'tcx ty::Slice>, (self, f, cx) { + ('tcx) &'tcx ty::List>, (self, f, cx) { display { // Generate the main trait ref, including associated types. ty::tls::with(|tcx| { @@ -672,7 +672,7 @@ impl<'tcx> fmt::Debug for ty::UpvarBorrow<'tcx> { } define_print! { - ('tcx) &'tcx ty::Slice>, (self, f, cx) { + ('tcx) &'tcx ty::List>, (self, f, cx) { display { write!(f, "{{")?; let mut tys = self.iter(); @@ -993,7 +993,7 @@ impl fmt::Debug for ty::FloatVarValue { define_print_multi! { [ - ('tcx) ty::Binder<&'tcx ty::Slice>>, + ('tcx) ty::Binder<&'tcx ty::List>>, ('tcx) ty::Binder>, ('tcx) ty::Binder>, ('tcx) ty::Binder>, diff --git a/src/librustc_mir/borrow_check/nll/type_check/relate_tys.rs b/src/librustc_mir/borrow_check/nll/type_check/relate_tys.rs index ac9bf65b61b..2509ad5c906 100644 --- a/src/librustc_mir/borrow_check/nll/type_check/relate_tys.rs +++ b/src/librustc_mir/borrow_check/nll/type_check/relate_tys.rs @@ -36,7 +36,7 @@ pub(super) fn sub_types<'tcx>( ty::Variance::Covariant, locations, borrowck_context, - ty::Slice::empty(), + ty::List::empty(), ).relate(&a, &b)?; Ok(()) } @@ -54,7 +54,7 @@ pub(super) fn eq_types<'tcx>( ty::Variance::Invariant, locations, borrowck_context, - ty::Slice::empty(), + ty::List::empty(), ).relate(&a, &b)?; Ok(()) } diff --git a/src/librustc_mir/borrow_check/nll/universal_regions.rs b/src/librustc_mir/borrow_check/nll/universal_regions.rs index 765c4cf906e..cd75cf54957 100644 --- a/src/librustc_mir/borrow_check/nll/universal_regions.rs +++ b/src/librustc_mir/borrow_check/nll/universal_regions.rs @@ -506,7 +506,7 @@ impl<'cx, 'gcx, 'tcx> UniversalRegionsBuilder<'cx, 'gcx, 'tcx> { &self, indices: &UniversalRegionIndices<'tcx>, defining_ty: DefiningTy<'tcx>, - ) -> ty::Binder<&'tcx ty::Slice>> { + ) -> ty::Binder<&'tcx ty::List>> { let tcx = self.infcx.tcx; match defining_ty { DefiningTy::Closure(def_id, substs) => { diff --git a/src/librustc_mir/transform/lower_128bit.rs b/src/librustc_mir/transform/lower_128bit.rs index 83cd7bf549d..acad0a1fa2c 100644 --- a/src/librustc_mir/transform/lower_128bit.rs +++ b/src/librustc_mir/transform/lower_128bit.rs @@ -13,7 +13,7 @@ use rustc::hir::def_id::DefId; use rustc::middle::lang_items::LangItem; use rustc::mir::*; -use rustc::ty::{Slice, Ty, TyCtxt, TypeVariants}; +use rustc::ty::{List, Ty, TyCtxt, TypeVariants}; use rustc_data_structures::indexed_vec::{Idx}; use transform::{MirPass, MirSource}; use syntax; @@ -114,7 +114,7 @@ impl Lower128Bit { source_info, kind: TerminatorKind::Call { func: Operand::function_handle(tcx, call_did, - Slice::empty(), source_info.span), + List::empty(), source_info.span), args: vec![lhs, rhs], destination: Some((place, bb)), cleanup: None, diff --git a/src/librustc_traits/lowering.rs b/src/librustc_traits/lowering.rs index a3c24f8af22..9fd3b318ec1 100644 --- a/src/librustc_traits/lowering.rs +++ b/src/librustc_traits/lowering.rs @@ -17,7 +17,7 @@ use rustc::traits::{ WhereClause, }; use rustc::ty::query::Providers; -use rustc::ty::{self, Slice, TyCtxt}; +use rustc::ty::{self, List, TyCtxt}; use rustc_data_structures::fx::FxHashSet; use std::mem; use syntax::ast; @@ -162,7 +162,7 @@ crate fn program_clauses_for<'a, 'tcx>( DefPathData::AssocTypeInImpl(..) => program_clauses_for_associated_type_value(tcx, def_id), DefPathData::AssocTypeInTrait(..) => program_clauses_for_associated_type_def(tcx, def_id), DefPathData::TypeNs(..) => program_clauses_for_type_def(tcx, def_id), - _ => Slice::empty(), + _ => List::empty(), } } @@ -319,7 +319,7 @@ fn program_clauses_for_trait<'a, 'tcx>( fn program_clauses_for_impl<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Clauses<'tcx> { if let ImplPolarity::Negative = tcx.impl_polarity(def_id) { - return Slice::empty(); + return List::empty(); } // Rule Implemented-From-Impl (see rustc guide) diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index ccdb751bc4e..9624fc36e0e 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -1666,7 +1666,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx>+'o { /// we return `None`. fn compute_object_lifetime_bound(&self, span: Span, - existential_predicates: ty::Binder<&'tcx ty::Slice>>) + existential_predicates: ty::Binder<&'tcx ty::List>>) -> Option> // if None, use the default { let tcx = self.tcx();