提交 87c7e570 编写于 作者: V varkor

Rename ty::Slice to ty::List

上级 674ef668
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
use mir; use mir;
impl<'a, 'gcx, T> HashStable<StableHashingContext<'a>> impl<'a, 'gcx, T> HashStable<StableHashingContext<'a>>
for &'gcx ty::Slice<T> for &'gcx ty::List<T>
where T: HashStable<StableHashingContext<'a>> { where T: HashStable<StableHashingContext<'a>> {
fn hash_stable<W: StableHasherResult>(&self, fn hash_stable<W: StableHasherResult>(&self,
hcx: &mut StableHashingContext<'a>, hcx: &mut StableHashingContext<'a>,
...@@ -53,7 +53,7 @@ fn hash_stable<W: StableHasherResult>(&self, ...@@ -53,7 +53,7 @@ fn hash_stable<W: StableHasherResult>(&self,
} }
} }
impl<'a, 'gcx, T> ToStableHashKey<StableHashingContext<'a>> for &'gcx ty::Slice<T> impl<'a, 'gcx, T> ToStableHashKey<StableHashingContext<'a>> for &'gcx ty::List<T>
where T: HashStable<StableHashingContext<'a>> where T: HashStable<StableHashingContext<'a>>
{ {
type KeyType = Fingerprint; type KeyType = Fingerprint;
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
use std::sync::atomic::Ordering; use std::sync::atomic::Ordering;
use ty::fold::{TypeFoldable, TypeFolder}; use ty::fold::{TypeFoldable, TypeFolder};
use ty::subst::Kind; 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::fx::FxHashMap;
use rustc_data_structures::indexed_vec::Idx; use rustc_data_structures::indexed_vec::Idx;
...@@ -327,7 +327,7 @@ fn canonicalize<V>( ...@@ -327,7 +327,7 @@ fn canonicalize<V>(
if !value.has_type_flags(needs_canonical_flags) { if !value.has_type_flags(needs_canonical_flags) {
let out_value = gcx.lift(value).unwrap(); let out_value = gcx.lift(value).unwrap();
let canon_value = Canonical { let canon_value = Canonical {
variables: Slice::empty(), variables: List::empty(),
value: out_value, value: out_value,
}; };
return canon_value; return canon_value;
......
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
use syntax::source_map::Span; use syntax::source_map::Span;
use ty::fold::TypeFoldable; use ty::fold::TypeFoldable;
use ty::subst::Kind; use ty::subst::Kind;
use ty::{self, CanonicalVar, Lift, Region, Slice, TyCtxt}; use ty::{self, CanonicalVar, Lift, Region, List, TyCtxt};
mod canonicalizer; mod canonicalizer;
...@@ -57,7 +57,7 @@ pub struct Canonical<'gcx, V> { ...@@ -57,7 +57,7 @@ pub struct Canonical<'gcx, V> {
pub value: V, pub value: V,
} }
pub type CanonicalVarInfos<'gcx> = &'gcx Slice<CanonicalVarInfo>; pub type CanonicalVarInfos<'gcx> = &'gcx List<CanonicalVarInfo>;
impl<'gcx> UseSpecializedDecodable for CanonicalVarInfos<'gcx> {} impl<'gcx> UseSpecializedDecodable for CanonicalVarInfos<'gcx> {}
...@@ -221,7 +221,7 @@ pub fn instantiate_canonical_with_fresh_inference_vars<T>( ...@@ -221,7 +221,7 @@ pub fn instantiate_canonical_with_fresh_inference_vars<T>(
fn fresh_inference_vars_for_canonical_vars( fn fresh_inference_vars_for_canonical_vars(
&self, &self,
span: Span, span: Span,
variables: &Slice<CanonicalVarInfo>, variables: &List<CanonicalVarInfo>,
) -> CanonicalVarValues<'tcx> { ) -> CanonicalVarValues<'tcx> {
let var_values: IndexVec<CanonicalVar, Kind<'tcx>> = variables let var_values: IndexVec<CanonicalVar, Kind<'tcx>> = variables
.iter() .iter()
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
use middle::region; use middle::region;
use mir::interpret::ConstEvalErr; use mir::interpret::ConstEvalErr;
use ty::subst::Substs; 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::error::{ExpectedFound, TypeError};
use ty::fold::{TypeFolder, TypeFoldable, TypeVisitor}; use ty::fold::{TypeFolder, TypeFoldable, TypeVisitor};
use infer::{InferCtxt}; use infer::{InferCtxt};
...@@ -325,7 +325,7 @@ pub enum Goal<'tcx> { ...@@ -325,7 +325,7 @@ pub enum Goal<'tcx> {
CannotProve, CannotProve,
} }
pub type Goals<'tcx> = &'tcx Slice<Goal<'tcx>>; pub type Goals<'tcx> = &'tcx List<Goal<'tcx>>;
impl<'tcx> DomainGoal<'tcx> { impl<'tcx> DomainGoal<'tcx> {
pub fn into_goal(self) -> Goal<'tcx> { pub fn into_goal(self) -> Goal<'tcx> {
...@@ -357,7 +357,7 @@ pub enum Clause<'tcx> { ...@@ -357,7 +357,7 @@ pub enum Clause<'tcx> {
} }
/// Multiple clauses. /// Multiple clauses.
pub type Clauses<'tcx> = &'tcx Slice<Clause<'tcx>>; pub type Clauses<'tcx> = &'tcx List<Clause<'tcx>>;
/// A "program clause" has the form `D :- G1, ..., Gn`. It is saying /// 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 /// that the domain goal `D` is true if `G1...Gn` are provable. This
......
...@@ -620,7 +620,7 @@ impl<'a, 'tcx> Lift<'tcx> for traits::Goal<'a> { ...@@ -620,7 +620,7 @@ impl<'a, 'tcx> Lift<'tcx> for traits::Goal<'a> {
} }
} }
impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::Slice<traits::Goal<'tcx>> { impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::List<traits::Goal<'tcx>> {
fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self {
let v = self.iter() let v = self.iter()
.map(|t| t.fold_with(folder)) .map(|t| t.fold_with(folder))
...@@ -658,7 +658,7 @@ impl<'tcx> TypeFoldable<'tcx> for traits::Clause<'tcx> { ...@@ -658,7 +658,7 @@ impl<'tcx> TypeFoldable<'tcx> for traits::Clause<'tcx> {
} }
} }
impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::Slice<traits::Clause<'tcx>> { impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::List<traits::Clause<'tcx>> {
fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self {
let v = self.iter() let v = self.iter()
.map(|t| t.fold_with(folder)) .map(|t| t.fold_with(folder))
......
...@@ -212,7 +212,7 @@ pub fn decode_region<'a, 'tcx, D>(decoder: &mut D) -> Result<ty::Region<'tcx>, D ...@@ -212,7 +212,7 @@ pub fn decode_region<'a, 'tcx, D>(decoder: &mut D) -> Result<ty::Region<'tcx>, D
#[inline] #[inline]
pub fn decode_ty_slice<'a, 'tcx, D>(decoder: &mut D) pub fn decode_ty_slice<'a, 'tcx, D>(decoder: &mut D)
-> Result<&'tcx ty::Slice<Ty<'tcx>>, D::Error> -> Result<&'tcx ty::List<Ty<'tcx>>, D::Error>
where D: TyDecoder<'a, 'tcx>, where D: TyDecoder<'a, 'tcx>,
'tcx: 'a, 'tcx: 'a,
{ {
...@@ -232,7 +232,7 @@ pub fn decode_adt_def<'a, 'tcx, D>(decoder: &mut D) ...@@ -232,7 +232,7 @@ pub fn decode_adt_def<'a, 'tcx, D>(decoder: &mut D)
#[inline] #[inline]
pub fn decode_existential_predicate_slice<'a, 'tcx, D>(decoder: &mut D) pub fn decode_existential_predicate_slice<'a, 'tcx, D>(decoder: &mut D)
-> Result<&'tcx ty::Slice<ty::ExistentialPredicate<'tcx>>, D::Error> -> Result<&'tcx ty::List<ty::ExistentialPredicate<'tcx>>, D::Error>
where D: TyDecoder<'a, 'tcx>, where D: TyDecoder<'a, 'tcx>,
'tcx: 'a, 'tcx: 'a,
{ {
...@@ -366,10 +366,10 @@ fn specialized_decode(&mut self) -> Result<ty::Region<'tcx>, Self::Error> { ...@@ -366,10 +366,10 @@ fn specialized_decode(&mut self) -> Result<ty::Region<'tcx>, Self::Error> {
} }
} }
impl<$($typaram),*> SpecializedDecoder<&'tcx ty::Slice<ty::Ty<'tcx>>> impl<$($typaram),*> SpecializedDecoder<&'tcx ty::List<ty::Ty<'tcx>>>
for $DecoderName<$($typaram),*> { for $DecoderName<$($typaram),*> {
fn specialized_decode(&mut self) fn specialized_decode(&mut self)
-> Result<&'tcx ty::Slice<ty::Ty<'tcx>>, Self::Error> { -> Result<&'tcx ty::List<ty::Ty<'tcx>>, Self::Error> {
decode_ty_slice(self) decode_ty_slice(self)
} }
} }
...@@ -381,10 +381,10 @@ fn specialized_decode(&mut self) -> Result<&'tcx ty::AdtDef, Self::Error> { ...@@ -381,10 +381,10 @@ fn specialized_decode(&mut self) -> Result<&'tcx ty::AdtDef, Self::Error> {
} }
} }
impl<$($typaram),*> SpecializedDecoder<&'tcx ty::Slice<ty::ExistentialPredicate<'tcx>>> impl<$($typaram),*> SpecializedDecoder<&'tcx ty::List<ty::ExistentialPredicate<'tcx>>>
for $DecoderName<$($typaram),*> { for $DecoderName<$($typaram),*> {
fn specialized_decode(&mut self) fn specialized_decode(&mut self)
-> Result<&'tcx ty::Slice<ty::ExistentialPredicate<'tcx>>, Self::Error> { -> Result<&'tcx ty::List<ty::ExistentialPredicate<'tcx>>, Self::Error> {
decode_existential_predicate_slice(self) decode_existential_predicate_slice(self)
} }
} }
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
use traits; use traits;
use traits::{Clause, Clauses, Goal, Goals}; use traits::{Clause, Clauses, Goal, Goals};
use ty::{self, Ty, TypeAndMut}; 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::{AdtKind, AdtDef, ClosureSubsts, GeneratorSubsts, Region, Const};
use ty::{PolyFnSig, InferTy, ParamTy, ProjectionTy, ExistentialPredicate, Predicate}; use ty::{PolyFnSig, InferTy, ParamTy, ProjectionTy, ExistentialPredicate, Predicate};
use ty::RegionKind; use ty::RegionKind;
...@@ -135,15 +135,15 @@ pub struct CtxtInterners<'tcx> { ...@@ -135,15 +135,15 @@ pub struct CtxtInterners<'tcx> {
/// Specifically use a speedy hash algorithm for these hash sets, /// Specifically use a speedy hash algorithm for these hash sets,
/// they're accessed quite often. /// they're accessed quite often.
type_: InternedSet<'tcx, TyS<'tcx>>, type_: InternedSet<'tcx, TyS<'tcx>>,
type_list: InternedSet<'tcx, Slice<Ty<'tcx>>>, type_list: InternedSet<'tcx, List<Ty<'tcx>>>,
substs: InternedSet<'tcx, Substs<'tcx>>, substs: InternedSet<'tcx, Substs<'tcx>>,
canonical_var_infos: InternedSet<'tcx, Slice<CanonicalVarInfo>>, canonical_var_infos: InternedSet<'tcx, List<CanonicalVarInfo>>,
region: InternedSet<'tcx, RegionKind>, region: InternedSet<'tcx, RegionKind>,
existential_predicates: InternedSet<'tcx, Slice<ExistentialPredicate<'tcx>>>, existential_predicates: InternedSet<'tcx, List<ExistentialPredicate<'tcx>>>,
predicates: InternedSet<'tcx, Slice<Predicate<'tcx>>>, predicates: InternedSet<'tcx, List<Predicate<'tcx>>>,
const_: InternedSet<'tcx, Const<'tcx>>, const_: InternedSet<'tcx, Const<'tcx>>,
clauses: InternedSet<'tcx, Slice<Clause<'tcx>>>, clauses: InternedSet<'tcx, List<Clause<'tcx>>>,
goals: InternedSet<'tcx, Slice<Goal<'tcx>>>, goals: InternedSet<'tcx, List<Goal<'tcx>>>,
} }
impl<'gcx: 'tcx, 'tcx> CtxtInterners<'tcx> { impl<'gcx: 'tcx, 'tcx> CtxtInterners<'tcx> {
...@@ -1593,12 +1593,12 @@ fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option<&'tcx Goa ...@@ -1593,12 +1593,12 @@ fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option<&'tcx Goa
} }
} }
impl<'a, 'tcx> Lift<'tcx> for &'a Slice<Goal<'a>> { impl<'a, 'tcx> Lift<'tcx> for &'a List<Goal<'a>> {
type Lifted = &'tcx Slice<Goal<'tcx>>; type Lifted = &'tcx List<Goal<'tcx>>;
fn lift_to_tcx<'b, 'gcx>( fn lift_to_tcx<'b, 'gcx>(
&self, &self,
tcx: TyCtxt<'b, 'gcx, 'tcx>, tcx: TyCtxt<'b, 'gcx, 'tcx>,
) -> Option<&'tcx Slice<Goal<'tcx>>> { ) -> Option<&'tcx List<Goal<'tcx>>> {
if tcx.interners.arena.in_arena(*self as *const _) { if tcx.interners.arena.in_arena(*self as *const _) {
return Some(unsafe { mem::transmute(*self) }); return Some(unsafe { mem::transmute(*self) });
} }
...@@ -1611,12 +1611,12 @@ fn lift_to_tcx<'b, 'gcx>( ...@@ -1611,12 +1611,12 @@ fn lift_to_tcx<'b, 'gcx>(
} }
} }
impl<'a, 'tcx> Lift<'tcx> for &'a Slice<Clause<'a>> { impl<'a, 'tcx> Lift<'tcx> for &'a List<Clause<'a>> {
type Lifted = &'tcx Slice<Clause<'tcx>>; type Lifted = &'tcx List<Clause<'tcx>>;
fn lift_to_tcx<'b, 'gcx>( fn lift_to_tcx<'b, 'gcx>(
&self, &self,
tcx: TyCtxt<'b, 'gcx, 'tcx>, tcx: TyCtxt<'b, 'gcx, 'tcx>,
) -> Option<&'tcx Slice<Clause<'tcx>>> { ) -> Option<&'tcx List<Clause<'tcx>>> {
if tcx.interners.arena.in_arena(*self as *const _) { if tcx.interners.arena.in_arena(*self as *const _) {
return Some(unsafe { mem::transmute(*self) }); return Some(unsafe { mem::transmute(*self) });
} }
...@@ -1648,7 +1648,7 @@ impl<'a, 'tcx> Lift<'tcx> for &'a Substs<'a> { ...@@ -1648,7 +1648,7 @@ impl<'a, 'tcx> Lift<'tcx> for &'a Substs<'a> {
type Lifted = &'tcx Substs<'tcx>; type Lifted = &'tcx Substs<'tcx>;
fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option<&'tcx Substs<'tcx>> { fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option<&'tcx Substs<'tcx>> {
if self.len() == 0 { if self.len() == 0 {
return Some(Slice::empty()); return Some(List::empty());
} }
if tcx.interners.arena.in_arena(&self[..] as *const _) { if tcx.interners.arena.in_arena(&self[..] as *const _) {
return Some(unsafe { mem::transmute(*self) }); return Some(unsafe { mem::transmute(*self) });
...@@ -1662,12 +1662,12 @@ fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option<&'tcx Sub ...@@ -1662,12 +1662,12 @@ fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option<&'tcx Sub
} }
} }
impl<'a, 'tcx> Lift<'tcx> for &'a Slice<Ty<'a>> { impl<'a, 'tcx> Lift<'tcx> for &'a List<Ty<'a>> {
type Lifted = &'tcx Slice<Ty<'tcx>>; type Lifted = &'tcx List<Ty<'tcx>>;
fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>)
-> Option<&'tcx Slice<Ty<'tcx>>> { -> Option<&'tcx List<Ty<'tcx>>> {
if self.len() == 0 { if self.len() == 0 {
return Some(Slice::empty()); return Some(List::empty());
} }
if tcx.interners.arena.in_arena(*self as *const _) { if tcx.interners.arena.in_arena(*self as *const _) {
return Some(unsafe { mem::transmute(*self) }); return Some(unsafe { mem::transmute(*self) });
...@@ -1681,12 +1681,12 @@ fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) ...@@ -1681,12 +1681,12 @@ fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>)
} }
} }
impl<'a, 'tcx> Lift<'tcx> for &'a Slice<ExistentialPredicate<'a>> { impl<'a, 'tcx> Lift<'tcx> for &'a List<ExistentialPredicate<'a>> {
type Lifted = &'tcx Slice<ExistentialPredicate<'tcx>>; type Lifted = &'tcx List<ExistentialPredicate<'tcx>>;
fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>)
-> Option<&'tcx Slice<ExistentialPredicate<'tcx>>> { -> Option<&'tcx List<ExistentialPredicate<'tcx>>> {
if self.is_empty() { if self.is_empty() {
return Some(Slice::empty()); return Some(List::empty());
} }
if tcx.interners.arena.in_arena(*self as *const _) { if tcx.interners.arena.in_arena(*self as *const _) {
return Some(unsafe { mem::transmute(*self) }); return Some(unsafe { mem::transmute(*self) });
...@@ -1700,12 +1700,12 @@ fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) ...@@ -1700,12 +1700,12 @@ fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>)
} }
} }
impl<'a, 'tcx> Lift<'tcx> for &'a Slice<Predicate<'a>> { impl<'a, 'tcx> Lift<'tcx> for &'a List<Predicate<'a>> {
type Lifted = &'tcx Slice<Predicate<'tcx>>; type Lifted = &'tcx List<Predicate<'tcx>>;
fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>)
-> Option<&'tcx Slice<Predicate<'tcx>>> { -> Option<&'tcx List<Predicate<'tcx>>> {
if self.is_empty() { if self.is_empty() {
return Some(Slice::empty()); return Some(List::empty());
} }
if tcx.interners.arena.in_arena(*self as *const _) { if tcx.interners.arena.in_arena(*self as *const _) {
return Some(unsafe { mem::transmute(*self) }); return Some(unsafe { mem::transmute(*self) });
...@@ -1719,11 +1719,11 @@ fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) ...@@ -1719,11 +1719,11 @@ fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>)
} }
} }
impl<'a, 'tcx> Lift<'tcx> for &'a Slice<CanonicalVarInfo> { impl<'a, 'tcx> Lift<'tcx> for &'a List<CanonicalVarInfo> {
type Lifted = &'tcx Slice<CanonicalVarInfo>; type Lifted = &'tcx List<CanonicalVarInfo>;
fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option<Self::Lifted> { fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option<Self::Lifted> {
if self.len() == 0 { if self.len() == 0 {
return Some(Slice::empty()); return Some(List::empty());
} }
if tcx.interners.arena.in_arena(*self as *const _) { if tcx.interners.arena.in_arena(*self as *const _) {
return Some(unsafe { mem::transmute(*self) }); return Some(unsafe { mem::transmute(*self) });
...@@ -2113,28 +2113,28 @@ fn borrow<'a>(&'a self) -> &'a TypeVariants<'lcx> { ...@@ -2113,28 +2113,28 @@ fn borrow<'a>(&'a self) -> &'a TypeVariants<'lcx> {
} }
} }
// NB: An Interned<Slice<T>> compares and hashes as its elements. // NB: An Interned<List<T>> compares and hashes as its elements.
impl<'tcx, T: PartialEq> PartialEq for Interned<'tcx, Slice<T>> { impl<'tcx, T: PartialEq> PartialEq for Interned<'tcx, List<T>> {
fn eq(&self, other: &Interned<'tcx, Slice<T>>) -> bool { fn eq(&self, other: &Interned<'tcx, List<T>>) -> bool {
self.0[..] == other.0[..] self.0[..] == other.0[..]
} }
} }
impl<'tcx, T: Eq> Eq for Interned<'tcx, Slice<T>> {} impl<'tcx, T: Eq> Eq for Interned<'tcx, List<T>> {}
impl<'tcx, T: Hash> Hash for Interned<'tcx, Slice<T>> { impl<'tcx, T: Hash> Hash for Interned<'tcx, List<T>> {
fn hash<H: Hasher>(&self, s: &mut H) { fn hash<H: Hasher>(&self, s: &mut H) {
self.0[..].hash(s) self.0[..].hash(s)
} }
} }
impl<'tcx: 'lcx, 'lcx> Borrow<[Ty<'lcx>]> for Interned<'tcx, Slice<Ty<'tcx>>> { impl<'tcx: 'lcx, 'lcx> Borrow<[Ty<'lcx>]> for Interned<'tcx, List<Ty<'tcx>>> {
fn borrow<'a>(&'a self) -> &'a [Ty<'lcx>] { fn borrow<'a>(&'a self) -> &'a [Ty<'lcx>] {
&self.0[..] &self.0[..]
} }
} }
impl<'tcx: 'lcx, 'lcx> Borrow<[CanonicalVarInfo]> for Interned<'tcx, Slice<CanonicalVarInfo>> { impl<'tcx: 'lcx, 'lcx> Borrow<[CanonicalVarInfo]> for Interned<'tcx, List<CanonicalVarInfo>> {
fn borrow<'a>(&'a self) -> &'a [CanonicalVarInfo] { fn borrow<'a>(&'a self) -> &'a [CanonicalVarInfo] {
&self.0[..] &self.0[..]
} }
...@@ -2153,14 +2153,14 @@ fn borrow<'a>(&'a self) -> &'a RegionKind { ...@@ -2153,14 +2153,14 @@ fn borrow<'a>(&'a self) -> &'a RegionKind {
} }
impl<'tcx: 'lcx, 'lcx> Borrow<[ExistentialPredicate<'lcx>]> impl<'tcx: 'lcx, 'lcx> Borrow<[ExistentialPredicate<'lcx>]>
for Interned<'tcx, Slice<ExistentialPredicate<'tcx>>> { for Interned<'tcx, List<ExistentialPredicate<'tcx>>> {
fn borrow<'a>(&'a self) -> &'a [ExistentialPredicate<'lcx>] { fn borrow<'a>(&'a self) -> &'a [ExistentialPredicate<'lcx>] {
&self.0[..] &self.0[..]
} }
} }
impl<'tcx: 'lcx, 'lcx> Borrow<[Predicate<'lcx>]> impl<'tcx: 'lcx, 'lcx> Borrow<[Predicate<'lcx>]>
for Interned<'tcx, Slice<Predicate<'tcx>>> { for Interned<'tcx, List<Predicate<'tcx>>> {
fn borrow<'a>(&'a self) -> &'a [Predicate<'lcx>] { fn borrow<'a>(&'a self) -> &'a [Predicate<'lcx>] {
&self.0[..] &self.0[..]
} }
...@@ -2173,14 +2173,14 @@ fn borrow<'a>(&'a self) -> &'a Const<'lcx> { ...@@ -2173,14 +2173,14 @@ fn borrow<'a>(&'a self) -> &'a Const<'lcx> {
} }
impl<'tcx: 'lcx, 'lcx> Borrow<[Clause<'lcx>]> impl<'tcx: 'lcx, 'lcx> Borrow<[Clause<'lcx>]>
for Interned<'tcx, Slice<Clause<'tcx>>> { for Interned<'tcx, List<Clause<'tcx>>> {
fn borrow<'a>(&'a self) -> &'a [Clause<'lcx>] { fn borrow<'a>(&'a self) -> &'a [Clause<'lcx>] {
&self.0[..] &self.0[..]
} }
} }
impl<'tcx: 'lcx, 'lcx> Borrow<[Goal<'lcx>]> impl<'tcx: 'lcx, 'lcx> Borrow<[Goal<'lcx>]>
for Interned<'tcx, Slice<Goal<'tcx>>> { for Interned<'tcx, List<Goal<'tcx>>> {
fn borrow<'a>(&'a self) -> &'a [Goal<'lcx>] { fn borrow<'a>(&'a self) -> &'a [Goal<'lcx>] {
&self.0[..] &self.0[..]
} }
...@@ -2274,9 +2274,9 @@ pub fn keep_local<'tcx, T: ty::TypeFoldable<'tcx>>(x: &T) -> bool { ...@@ -2274,9 +2274,9 @@ pub fn keep_local<'tcx, T: ty::TypeFoldable<'tcx>>(x: &T) -> bool {
($($field:ident: $method:ident($ty:ident)),+) => ( ($($field:ident: $method:ident($ty:ident)),+) => (
$(intern_method!( 'tcx, $field: $method( $(intern_method!( 'tcx, $field: $method(
&[$ty<'tcx>], &[$ty<'tcx>],
|a, v| Slice::from_arena(a, v), |a, v| List::from_arena(a, v),
Deref::deref, 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 @@ pub fn keep_local<'tcx, T: ty::TypeFoldable<'tcx>>(x: &T) -> bool { ...@@ -2298,10 +2298,10 @@ pub fn keep_local<'tcx, T: ty::TypeFoldable<'tcx>>(x: &T) -> bool {
'tcx, 'tcx,
canonical_var_infos: _intern_canonical_var_infos( canonical_var_infos: _intern_canonical_var_infos(
&[CanonicalVarInfo], &[CanonicalVarInfo],
|a, v| Slice::from_arena(a, v), |a, v| List::from_arena(a, v),
Deref::deref, Deref::deref,
|_xs: &[CanonicalVarInfo]| -> bool { false } |_xs: &[CanonicalVarInfo]| -> bool { false }
) -> Slice<CanonicalVarInfo> ) -> List<CanonicalVarInfo>
} }
impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
...@@ -2480,7 +2480,7 @@ pub fn mk_fn_ptr(self, fty: PolyFnSig<'tcx>) -> Ty<'tcx> { ...@@ -2480,7 +2480,7 @@ pub fn mk_fn_ptr(self, fty: PolyFnSig<'tcx>) -> Ty<'tcx> {
pub fn mk_dynamic( pub fn mk_dynamic(
self, self,
obj: ty::Binder<&'tcx Slice<ExistentialPredicate<'tcx>>>, obj: ty::Binder<&'tcx List<ExistentialPredicate<'tcx>>>,
reg: ty::Region<'tcx> reg: ty::Region<'tcx>
) -> Ty<'tcx> { ) -> Ty<'tcx> {
self.mk_ty(TyDynamic(obj, reg)) self.mk_ty(TyDynamic(obj, reg))
...@@ -2509,7 +2509,7 @@ pub fn mk_generator(self, ...@@ -2509,7 +2509,7 @@ pub fn mk_generator(self,
self.mk_ty(TyGenerator(id, generator_substs, movability)) self.mk_ty(TyGenerator(id, generator_substs, movability))
} }
pub fn mk_generator_witness(self, types: ty::Binder<&'tcx Slice<Ty<'tcx>>>) -> Ty<'tcx> { pub fn mk_generator_witness(self, types: ty::Binder<&'tcx List<Ty<'tcx>>>) -> Ty<'tcx> {
self.mk_ty(TyGeneratorWitness(types)) self.mk_ty(TyGeneratorWitness(types))
} }
...@@ -2553,36 +2553,36 @@ pub fn mk_anon(self, def_id: DefId, substs: &'tcx Substs<'tcx>) -> Ty<'tcx> { ...@@ -2553,36 +2553,36 @@ pub fn mk_anon(self, def_id: DefId, substs: &'tcx Substs<'tcx>) -> Ty<'tcx> {
} }
pub fn intern_existential_predicates(self, eps: &[ExistentialPredicate<'tcx>]) pub fn intern_existential_predicates(self, eps: &[ExistentialPredicate<'tcx>])
-> &'tcx Slice<ExistentialPredicate<'tcx>> { -> &'tcx List<ExistentialPredicate<'tcx>> {
assert!(!eps.is_empty()); assert!(!eps.is_empty());
assert!(eps.windows(2).all(|w| w[0].stable_cmp(self, &w[1]) != Ordering::Greater)); assert!(eps.windows(2).all(|w| w[0].stable_cmp(self, &w[1]) != Ordering::Greater));
self._intern_existential_predicates(eps) self._intern_existential_predicates(eps)
} }
pub fn intern_predicates(self, preds: &[Predicate<'tcx>]) pub fn intern_predicates(self, preds: &[Predicate<'tcx>])
-> &'tcx Slice<Predicate<'tcx>> { -> &'tcx List<Predicate<'tcx>> {
// FIXME consider asking the input slice to be sorted to avoid // FIXME consider asking the input slice to be sorted to avoid
// re-interning permutations, in which case that would be asserted // re-interning permutations, in which case that would be asserted
// here. // here.
if preds.len() == 0 { if preds.len() == 0 {
// The macro-generated method below asserts we don't intern an empty slice. // The macro-generated method below asserts we don't intern an empty slice.
Slice::empty() List::empty()
} else { } else {
self._intern_predicates(preds) self._intern_predicates(preds)
} }
} }
pub fn intern_type_list(self, ts: &[Ty<'tcx>]) -> &'tcx Slice<Ty<'tcx>> { pub fn intern_type_list(self, ts: &[Ty<'tcx>]) -> &'tcx List<Ty<'tcx>> {
if ts.len() == 0 { if ts.len() == 0 {
Slice::empty() List::empty()
} else { } else {
self._intern_type_list(ts) self._intern_type_list(ts)
} }
} }
pub fn intern_substs(self, ts: &[Kind<'tcx>]) -> &'tcx Slice<Kind<'tcx>> { pub fn intern_substs(self, ts: &[Kind<'tcx>]) -> &'tcx List<Kind<'tcx>> {
if ts.len() == 0 { if ts.len() == 0 {
Slice::empty() List::empty()
} else { } else {
self._intern_substs(ts) self._intern_substs(ts)
} }
...@@ -2590,7 +2590,7 @@ pub fn intern_substs(self, ts: &[Kind<'tcx>]) -> &'tcx Slice<Kind<'tcx>> { ...@@ -2590,7 +2590,7 @@ pub fn intern_substs(self, ts: &[Kind<'tcx>]) -> &'tcx Slice<Kind<'tcx>> {
pub fn intern_canonical_var_infos(self, ts: &[CanonicalVarInfo]) -> CanonicalVarInfos<'gcx> { pub fn intern_canonical_var_infos(self, ts: &[CanonicalVarInfo]) -> CanonicalVarInfos<'gcx> {
if ts.len() == 0 { if ts.len() == 0 {
Slice::empty() List::empty()
} else { } else {
self.global_tcx()._intern_canonical_var_infos(ts) self.global_tcx()._intern_canonical_var_infos(ts)
} }
...@@ -2598,7 +2598,7 @@ pub fn intern_canonical_var_infos(self, ts: &[CanonicalVarInfo]) -> CanonicalVar ...@@ -2598,7 +2598,7 @@ pub fn intern_canonical_var_infos(self, ts: &[CanonicalVarInfo]) -> CanonicalVar
pub fn intern_clauses(self, ts: &[Clause<'tcx>]) -> Clauses<'tcx> { pub fn intern_clauses(self, ts: &[Clause<'tcx>]) -> Clauses<'tcx> {
if ts.len() == 0 { if ts.len() == 0 {
Slice::empty() List::empty()
} else { } else {
self._intern_clauses(ts) self._intern_clauses(ts)
} }
...@@ -2606,7 +2606,7 @@ pub fn intern_clauses(self, ts: &[Clause<'tcx>]) -> Clauses<'tcx> { ...@@ -2606,7 +2606,7 @@ pub fn intern_clauses(self, ts: &[Clause<'tcx>]) -> Clauses<'tcx> {
pub fn intern_goals(self, ts: &[Goal<'tcx>]) -> Goals<'tcx> { pub fn intern_goals(self, ts: &[Goal<'tcx>]) -> Goals<'tcx> {
if ts.len() == 0 { if ts.len() == 0 {
Slice::empty() List::empty()
} else { } else {
self._intern_goals(ts) self._intern_goals(ts)
} }
...@@ -2629,24 +2629,24 @@ pub fn mk_fn_sig<I>(self, ...@@ -2629,24 +2629,24 @@ pub fn mk_fn_sig<I>(self,
} }
pub fn mk_existential_predicates<I: InternAs<[ExistentialPredicate<'tcx>], pub fn mk_existential_predicates<I: InternAs<[ExistentialPredicate<'tcx>],
&'tcx Slice<ExistentialPredicate<'tcx>>>>(self, iter: I) &'tcx List<ExistentialPredicate<'tcx>>>>(self, iter: I)
-> I::Output { -> I::Output {
iter.intern_with(|xs| self.intern_existential_predicates(xs)) iter.intern_with(|xs| self.intern_existential_predicates(xs))
} }
pub fn mk_predicates<I: InternAs<[Predicate<'tcx>], pub fn mk_predicates<I: InternAs<[Predicate<'tcx>],
&'tcx Slice<Predicate<'tcx>>>>(self, iter: I) &'tcx List<Predicate<'tcx>>>>(self, iter: I)
-> I::Output { -> I::Output {
iter.intern_with(|xs| self.intern_predicates(xs)) iter.intern_with(|xs| self.intern_predicates(xs))
} }
pub fn mk_type_list<I: InternAs<[Ty<'tcx>], pub fn mk_type_list<I: InternAs<[Ty<'tcx>],
&'tcx Slice<Ty<'tcx>>>>(self, iter: I) -> I::Output { &'tcx List<Ty<'tcx>>>>(self, iter: I) -> I::Output {
iter.intern_with(|xs| self.intern_type_list(xs)) iter.intern_with(|xs| self.intern_type_list(xs))
} }
pub fn mk_substs<I: InternAs<[Kind<'tcx>], pub fn mk_substs<I: InternAs<[Kind<'tcx>],
&'tcx Slice<Kind<'tcx>>>>(self, iter: I) -> I::Output { &'tcx List<Kind<'tcx>>>>(self, iter: I) -> I::Output {
iter.intern_with(|xs| self.intern_substs(xs)) iter.intern_with(|xs| self.intern_substs(xs))
} }
......
...@@ -51,7 +51,7 @@ pub enum TypeError<'tcx> { ...@@ -51,7 +51,7 @@ pub enum TypeError<'tcx> {
CyclicTy(Ty<'tcx>), CyclicTy(Ty<'tcx>),
ProjectionMismatched(ExpectedFound<DefId>), ProjectionMismatched(ExpectedFound<DefId>),
ProjectionBoundsLength(ExpectedFound<usize>), ProjectionBoundsLength(ExpectedFound<usize>),
ExistentialMismatch(ExpectedFound<&'tcx ty::Slice<ty::ExistentialPredicate<'tcx>>>), ExistentialMismatch(ExpectedFound<&'tcx ty::List<ty::ExistentialPredicate<'tcx>>>),
OldStyleLUB(Box<TypeError<'tcx>>), OldStyleLUB(Box<TypeError<'tcx>>),
} }
......
...@@ -596,8 +596,8 @@ impl<'tcx> serialize::UseSpecializedDecodable for Ty<'tcx> {} ...@@ -596,8 +596,8 @@ impl<'tcx> serialize::UseSpecializedDecodable for Ty<'tcx> {}
pub type CanonicalTy<'gcx> = Canonical<'gcx, Ty<'gcx>>; pub type CanonicalTy<'gcx> = Canonical<'gcx, Ty<'gcx>>;
extern { extern {
/// A dummy type used to force Slice to by unsized without requiring fat pointers /// A dummy type used to force List to by unsized without requiring fat pointers
type OpaqueSliceContents; type OpaqueListContents;
} }
/// A wrapper for slices with the additional invariant /// A wrapper for slices with the additional invariant
...@@ -605,18 +605,19 @@ impl<'tcx> serialize::UseSpecializedDecodable for Ty<'tcx> {} ...@@ -605,18 +605,19 @@ impl<'tcx> serialize::UseSpecializedDecodable for Ty<'tcx> {}
/// the same contents can exist in the same context. /// the same contents can exist in the same context.
/// This means we can use pointer for both /// This means we can use pointer for both
/// equality comparisons and hashing. /// equality comparisons and hashing.
/// Note: `Slice` was already taken by the `Ty`.
#[repr(C)] #[repr(C)]
pub struct Slice<T> { pub struct List<T> {
len: usize, len: usize,
data: [T; 0], data: [T; 0],
opaque: OpaqueSliceContents, opaque: OpaqueListContents,
} }
unsafe impl<T: Sync> Sync for Slice<T> {} unsafe impl<T: Sync> Sync for List<T> {}
impl<T: Copy> Slice<T> { impl<T: Copy> List<T> {
#[inline] #[inline]
fn from_arena<'tcx>(arena: &'tcx SyncDroplessArena, slice: &[T]) -> &'tcx Slice<T> { fn from_arena<'tcx>(arena: &'tcx SyncDroplessArena, slice: &[T]) -> &'tcx List<T> {
assert!(!mem::needs_drop::<T>()); assert!(!mem::needs_drop::<T>());
assert!(mem::size_of::<T>() != 0); assert!(mem::size_of::<T>() != 0);
assert!(slice.len() != 0); assert!(slice.len() != 0);
...@@ -633,7 +634,7 @@ fn from_arena<'tcx>(arena: &'tcx SyncDroplessArena, slice: &[T]) -> &'tcx Slice< ...@@ -633,7 +634,7 @@ fn from_arena<'tcx>(arena: &'tcx SyncDroplessArena, slice: &[T]) -> &'tcx Slice<
size, size,
cmp::max(mem::align_of::<T>(), mem::align_of::<usize>())); cmp::max(mem::align_of::<T>(), mem::align_of::<usize>()));
unsafe { unsafe {
let result = &mut *(mem.as_mut_ptr() as *mut Slice<T>); let result = &mut *(mem.as_mut_ptr() as *mut List<T>);
// Write the length // Write the length
result.len = slice.len(); result.len = slice.len();
...@@ -646,51 +647,51 @@ fn from_arena<'tcx>(arena: &'tcx SyncDroplessArena, slice: &[T]) -> &'tcx Slice< ...@@ -646,51 +647,51 @@ fn from_arena<'tcx>(arena: &'tcx SyncDroplessArena, slice: &[T]) -> &'tcx Slice<
} }
} }
impl<T: fmt::Debug> fmt::Debug for Slice<T> { impl<T: fmt::Debug> fmt::Debug for List<T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
(**self).fmt(f) (**self).fmt(f)
} }
} }
impl<T: Encodable> Encodable for Slice<T> { impl<T: Encodable> Encodable for List<T> {
#[inline] #[inline]
fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> { fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> {
(**self).encode(s) (**self).encode(s)
} }
} }
impl<T> Ord for Slice<T> where T: Ord { impl<T> Ord for List<T> where T: Ord {
fn cmp(&self, other: &Slice<T>) -> Ordering { fn cmp(&self, other: &List<T>) -> Ordering {
if self == other { Ordering::Equal } else { if self == other { Ordering::Equal } else {
<[T] as Ord>::cmp(&**self, &**other) <[T] as Ord>::cmp(&**self, &**other)
} }
} }
} }
impl<T> PartialOrd for Slice<T> where T: PartialOrd { impl<T> PartialOrd for List<T> where T: PartialOrd {
fn partial_cmp(&self, other: &Slice<T>) -> Option<Ordering> { fn partial_cmp(&self, other: &List<T>) -> Option<Ordering> {
if self == other { Some(Ordering::Equal) } else { if self == other { Some(Ordering::Equal) } else {
<[T] as PartialOrd>::partial_cmp(&**self, &**other) <[T] as PartialOrd>::partial_cmp(&**self, &**other)
} }
} }
} }
impl<T: PartialEq> PartialEq for Slice<T> { impl<T: PartialEq> PartialEq for List<T> {
#[inline] #[inline]
fn eq(&self, other: &Slice<T>) -> bool { fn eq(&self, other: &List<T>) -> bool {
ptr::eq(self, other) ptr::eq(self, other)
} }
} }
impl<T: Eq> Eq for Slice<T> {} impl<T: Eq> Eq for List<T> {}
impl<T> Hash for Slice<T> { impl<T> Hash for List<T> {
#[inline] #[inline]
fn hash<H: Hasher>(&self, s: &mut H) { fn hash<H: Hasher>(&self, s: &mut H) {
(self as *const Slice<T>).hash(s) (self as *const List<T>).hash(s)
} }
} }
impl<T> Deref for Slice<T> { impl<T> Deref for List<T> {
type Target = [T]; type Target = [T];
#[inline(always)] #[inline(always)]
fn deref(&self) -> &[T] { fn deref(&self) -> &[T] {
...@@ -700,7 +701,7 @@ fn deref(&self) -> &[T] { ...@@ -700,7 +701,7 @@ fn deref(&self) -> &[T] {
} }
} }
impl<'a, T> IntoIterator for &'a Slice<T> { impl<'a, T> IntoIterator for &'a List<T> {
type Item = &'a T; type Item = &'a T;
type IntoIter = <&'a [T] as IntoIterator>::IntoIter; type IntoIter = <&'a [T] as IntoIterator>::IntoIter;
#[inline(always)] #[inline(always)]
...@@ -709,17 +710,17 @@ fn into_iter(self) -> Self::IntoIter { ...@@ -709,17 +710,17 @@ fn into_iter(self) -> Self::IntoIter {
} }
} }
impl<'tcx> serialize::UseSpecializedDecodable for &'tcx Slice<Ty<'tcx>> {} impl<'tcx> serialize::UseSpecializedDecodable for &'tcx List<Ty<'tcx>> {}
impl<T> Slice<T> { impl<T> List<T> {
#[inline(always)] #[inline(always)]
pub fn empty<'a>() -> &'a Slice<T> { pub fn empty<'a>() -> &'a List<T> {
#[repr(align(64), C)] #[repr(align(64), C)]
struct EmptySlice([u8; 64]); struct EmptySlice([u8; 64]);
static EMPTY_SLICE: EmptySlice = EmptySlice([0; 64]); static EMPTY_SLICE: EmptySlice = EmptySlice([0; 64]);
assert!(mem::align_of::<T>() <= 64); assert!(mem::align_of::<T>() <= 64);
unsafe { unsafe {
&*(&EMPTY_SLICE as *const _ as *const Slice<T>) &*(&EMPTY_SLICE as *const _ as *const List<T>)
} }
} }
} }
...@@ -1556,7 +1557,7 @@ pub struct ParamEnv<'tcx> { ...@@ -1556,7 +1557,7 @@ pub struct ParamEnv<'tcx> {
/// Obligations that the caller must satisfy. This is basically /// Obligations that the caller must satisfy. This is basically
/// the set of bounds on the in-scope type parameters, translated /// the set of bounds on the in-scope type parameters, translated
/// into Obligations, and elaborated and normalized. /// into Obligations, and elaborated and normalized.
pub caller_bounds: &'tcx Slice<ty::Predicate<'tcx>>, pub caller_bounds: &'tcx List<ty::Predicate<'tcx>>,
/// Typically, this is `Reveal::UserFacing`, but during codegen we /// Typically, this is `Reveal::UserFacing`, but during codegen we
/// want `Reveal::All` -- note that this is always paired with an /// want `Reveal::All` -- note that this is always paired with an
...@@ -1570,7 +1571,7 @@ impl<'tcx> ParamEnv<'tcx> { ...@@ -1570,7 +1571,7 @@ impl<'tcx> ParamEnv<'tcx> {
/// Trait`) are left hidden, so this is suitable for ordinary /// Trait`) are left hidden, so this is suitable for ordinary
/// type-checking. /// type-checking.
pub fn empty() -> Self { 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 /// Construct a trait environment with no where clauses in scope
...@@ -1581,11 +1582,11 @@ pub fn empty() -> Self { ...@@ -1581,11 +1582,11 @@ pub fn empty() -> Self {
/// NB. If you want to have predicates in scope, use `ParamEnv::new`, /// NB. If you want to have predicates in scope, use `ParamEnv::new`,
/// or invoke `param_env.with_reveal_all()`. /// or invoke `param_env.with_reveal_all()`.
pub fn reveal_all() -> Self { 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. /// Construct a trait environment with the given set of predicates.
pub fn new(caller_bounds: &'tcx ty::Slice<ty::Predicate<'tcx>>, pub fn new(caller_bounds: &'tcx List<ty::Predicate<'tcx>>,
reveal: Reveal) reveal: Reveal)
-> Self { -> Self {
ty::ParamEnv { caller_bounds, reveal } ty::ParamEnv { caller_bounds, reveal }
...@@ -1603,7 +1604,7 @@ pub fn with_reveal_all(self) -> Self { ...@@ -1603,7 +1604,7 @@ pub fn with_reveal_all(self) -> Self {
/// Returns this same environment but with no caller bounds. /// Returns this same environment but with no caller bounds.
pub fn without_caller_bounds(self) -> Self { 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 /// Creates a suitable environment in which to perform trait
......
...@@ -316,7 +316,7 @@ fn relate<'a, 'gcx, R>(relation: &mut R, ...@@ -316,7 +316,7 @@ fn relate<'a, 'gcx, R>(relation: &mut R,
} }
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
struct GeneratorWitness<'tcx>(&'tcx ty::Slice<Ty<'tcx>>); struct GeneratorWitness<'tcx>(&'tcx ty::List<Ty<'tcx>>);
TupleStructTypeFoldableImpl! { TupleStructTypeFoldableImpl! {
impl<'tcx> TypeFoldable<'tcx> for GeneratorWitness<'tcx> { impl<'tcx> TypeFoldable<'tcx> for GeneratorWitness<'tcx> {
...@@ -578,7 +578,7 @@ pub fn super_relate_tys<'a, 'gcx, 'tcx, R>(relation: &mut R, ...@@ -578,7 +578,7 @@ pub fn super_relate_tys<'a, 'gcx, 'tcx, R>(relation: &mut R,
} }
} }
impl<'tcx> Relate<'tcx> for &'tcx ty::Slice<ty::ExistentialPredicate<'tcx>> { impl<'tcx> Relate<'tcx> for &'tcx ty::List<ty::ExistentialPredicate<'tcx>> {
fn relate<'a, 'gcx, R>(relation: &mut R, fn relate<'a, 'gcx, R>(relation: &mut R,
a: &Self, a: &Self,
b: &Self) b: &Self)
......
...@@ -735,7 +735,7 @@ fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool { ...@@ -735,7 +735,7 @@ fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
impl<'tcx> TypeFoldable<'tcx> for ty::ParamEnv<'tcx> { reveal, caller_bounds } impl<'tcx> TypeFoldable<'tcx> for ty::ParamEnv<'tcx> { reveal, caller_bounds }
} }
impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::Slice<ty::ExistentialPredicate<'tcx>> { impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::List<ty::ExistentialPredicate<'tcx>> {
fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { 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::<AccumulateVec<[_; 8]>>(); let v = self.iter().map(|p| p.fold_with(folder)).collect::<AccumulateVec<[_; 8]>>();
folder.tcx().intern_existential_predicates(&v) folder.tcx().intern_existential_predicates(&v)
...@@ -754,7 +754,7 @@ impl<'tcx> TypeFoldable<'tcx> for ty::ExistentialPredicate<'tcx> { ...@@ -754,7 +754,7 @@ impl<'tcx> TypeFoldable<'tcx> for ty::ExistentialPredicate<'tcx> {
} }
} }
impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::Slice<Ty<'tcx>> { impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::List<Ty<'tcx>> {
fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { 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::<AccumulateVec<[_; 8]>>(); let v = self.iter().map(|t| t.fold_with(folder)).collect::<AccumulateVec<[_; 8]>>();
folder.tcx().intern_type_list(&v) folder.tcx().intern_type_list(&v)
...@@ -1010,7 +1010,7 @@ impl<'tcx> TypeFoldable<'tcx> for ty::GenericPredicates<'tcx> { ...@@ -1010,7 +1010,7 @@ impl<'tcx> TypeFoldable<'tcx> for ty::GenericPredicates<'tcx> {
} }
} }
impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::Slice<ty::Predicate<'tcx>> { impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::List<ty::Predicate<'tcx>> {
fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { 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::<AccumulateVec<[_; 8]>>(); let v = self.iter().map(|p| p.fold_with(folder)).collect::<AccumulateVec<[_; 8]>>();
folder.tcx().intern_predicates(&v) folder.tcx().intern_predicates(&v)
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
use rustc_data_structures::indexed_vec::Idx; use rustc_data_structures::indexed_vec::Idx;
use ty::subst::{Substs, Subst, Kind, UnpackedKind}; use ty::subst::{Substs, Subst, Kind, UnpackedKind};
use ty::{self, AdtDef, TypeFlags, Ty, TyCtxt, TypeFoldable}; 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 util::captures::Captures;
use mir::interpret::{Scalar, Pointer}; use mir::interpret::{Scalar, Pointer};
...@@ -133,7 +133,7 @@ pub enum TypeVariants<'tcx> { ...@@ -133,7 +133,7 @@ pub enum TypeVariants<'tcx> {
TyFnPtr(PolyFnSig<'tcx>), TyFnPtr(PolyFnSig<'tcx>),
/// A trait, defined with `trait`. /// A trait, defined with `trait`.
TyDynamic(Binder<&'tcx Slice<ExistentialPredicate<'tcx>>>, ty::Region<'tcx>), TyDynamic(Binder<&'tcx List<ExistentialPredicate<'tcx>>>, ty::Region<'tcx>),
/// The anonymous type of a closure. Used to represent the type of /// The anonymous type of a closure. Used to represent the type of
/// `|a| a`. /// `|a| a`.
...@@ -145,13 +145,13 @@ pub enum TypeVariants<'tcx> { ...@@ -145,13 +145,13 @@ pub enum TypeVariants<'tcx> {
/// A type representin the types stored inside a generator. /// A type representin the types stored inside a generator.
/// This should only appear in GeneratorInteriors. /// This should only appear in GeneratorInteriors.
TyGeneratorWitness(Binder<&'tcx Slice<Ty<'tcx>>>), TyGeneratorWitness(Binder<&'tcx List<Ty<'tcx>>>),
/// The never type `!` /// The never type `!`
TyNever, TyNever,
/// A tuple type. For example, `(i32, bool)`. /// A tuple type. For example, `(i32, bool)`.
TyTuple(&'tcx Slice<Ty<'tcx>>), TyTuple(&'tcx List<Ty<'tcx>>),
/// The projection of an associated type. For example, /// The projection of an associated type. For example,
/// `<T as Trait<..>>::N`. /// `<T as Trait<..>>::N`.
...@@ -536,9 +536,9 @@ pub fn with_self_ty(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>, self_ty: Ty<'tcx>) ...@@ -536,9 +536,9 @@ pub fn with_self_ty(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>, self_ty: Ty<'tcx>)
} }
} }
impl<'tcx> serialize::UseSpecializedDecodable for &'tcx Slice<ExistentialPredicate<'tcx>> {} impl<'tcx> serialize::UseSpecializedDecodable for &'tcx List<ExistentialPredicate<'tcx>> {}
impl<'tcx> Slice<ExistentialPredicate<'tcx>> { impl<'tcx> List<ExistentialPredicate<'tcx>> {
pub fn principal(&self) -> Option<ExistentialTraitRef<'tcx>> { pub fn principal(&self) -> Option<ExistentialTraitRef<'tcx>> {
match self.get(0) { match self.get(0) {
Some(&ExistentialPredicate::Trait(tr)) => Some(tr), Some(&ExistentialPredicate::Trait(tr)) => Some(tr),
...@@ -568,7 +568,7 @@ pub fn auto_traits<'a>(&'a self) -> impl Iterator<Item=DefId> + 'a { ...@@ -568,7 +568,7 @@ pub fn auto_traits<'a>(&'a self) -> impl Iterator<Item=DefId> + 'a {
} }
} }
impl<'tcx> Binder<&'tcx Slice<ExistentialPredicate<'tcx>>> { impl<'tcx> Binder<&'tcx List<ExistentialPredicate<'tcx>>> {
pub fn principal(&self) -> Option<PolyExistentialTraitRef<'tcx>> { pub fn principal(&self) -> Option<PolyExistentialTraitRef<'tcx>> {
self.skip_binder().principal().map(Binder::bind) self.skip_binder().principal().map(Binder::bind)
} }
...@@ -918,7 +918,7 @@ pub fn return_ty(&self) -> ty::Binder<Ty<'tcx>> { ...@@ -918,7 +918,7 @@ pub fn return_ty(&self) -> ty::Binder<Ty<'tcx>> {
/// - `variadic` indicates whether this is a variadic function. (only true for foreign fns) /// - `variadic` indicates whether this is a variadic function. (only true for foreign fns)
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable)] #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable)]
pub struct FnSig<'tcx> { pub struct FnSig<'tcx> {
pub inputs_and_output: &'tcx Slice<Ty<'tcx>>, pub inputs_and_output: &'tcx List<Ty<'tcx>>,
pub variadic: bool, pub variadic: bool,
pub unsafety: hir::Unsafety, pub unsafety: hir::Unsafety,
pub abi: abi::Abi, pub abi: abi::Abi,
...@@ -943,7 +943,7 @@ pub fn inputs(&self) -> Binder<&'tcx [Ty<'tcx>]> { ...@@ -943,7 +943,7 @@ pub fn inputs(&self) -> Binder<&'tcx [Ty<'tcx>]> {
pub fn input(&self, index: usize) -> ty::Binder<Ty<'tcx>> { pub fn input(&self, index: usize) -> ty::Binder<Ty<'tcx>> {
self.map_bound_ref(|fn_sig| fn_sig.inputs()[index]) self.map_bound_ref(|fn_sig| fn_sig.inputs()[index])
} }
pub fn inputs_and_output(&self) -> ty::Binder<&'tcx Slice<Ty<'tcx>>> { pub fn inputs_and_output(&self) -> ty::Binder<&'tcx List<Ty<'tcx>>> {
self.map_bound_ref(|fn_sig| fn_sig.inputs_and_output) self.map_bound_ref(|fn_sig| fn_sig.inputs_and_output)
} }
pub fn output(&self) -> ty::Binder<Ty<'tcx>> { pub fn output(&self) -> ty::Binder<Ty<'tcx>> {
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
// Type substitutions. // Type substitutions.
use hir::def_id::DefId; 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 ty::fold::{TypeFoldable, TypeFolder, TypeVisitor};
use serialize::{self, Encodable, Encoder, Decodable, Decoder}; use serialize::{self, Encodable, Encoder, Decodable, Decoder};
...@@ -177,7 +177,7 @@ fn decode<D: Decoder>(d: &mut D) -> Result<Kind<'tcx>, D::Error> { ...@@ -177,7 +177,7 @@ fn decode<D: Decoder>(d: &mut D) -> Result<Kind<'tcx>, D::Error> {
} }
/// A substitution mapping generic parameters to new values. /// A substitution mapping generic parameters to new values.
pub type Substs<'tcx> = Slice<Kind<'tcx>>; pub type Substs<'tcx> = List<Kind<'tcx>>;
impl<'a, 'gcx, 'tcx> Substs<'tcx> { impl<'a, 'gcx, 'tcx> Substs<'tcx> {
/// Creates a Substs that maps each generic parameter to itself. /// Creates a Substs that maps each generic parameter to itself.
......
...@@ -453,7 +453,7 @@ fn nominal_obligations(&mut self, ...@@ -453,7 +453,7 @@ fn nominal_obligations(&mut self,
} }
fn from_object_ty(&mut self, ty: Ty<'tcx>, fn from_object_ty(&mut self, ty: Ty<'tcx>,
data: ty::Binder<&'tcx ty::Slice<ty::ExistentialPredicate<'tcx>>>, data: ty::Binder<&'tcx ty::List<ty::ExistentialPredicate<'tcx>>>,
region: ty::Region<'tcx>) { region: ty::Region<'tcx>) {
// Imagine a type like this: // Imagine a type like this:
// //
...@@ -513,7 +513,7 @@ fn from_object_ty(&mut self, ty: Ty<'tcx>, ...@@ -513,7 +513,7 @@ fn from_object_ty(&mut self, ty: Ty<'tcx>,
/// `ty::required_region_bounds`, see that for more information. /// `ty::required_region_bounds`, see that for more information.
pub fn object_region_bounds<'a, 'gcx, 'tcx>( pub fn object_region_bounds<'a, 'gcx, 'tcx>(
tcx: TyCtxt<'a, 'gcx, 'tcx>, tcx: TyCtxt<'a, 'gcx, 'tcx>,
existential_predicates: ty::Binder<&'tcx ty::Slice<ty::ExistentialPredicate<'tcx>>>) existential_predicates: ty::Binder<&'tcx ty::List<ty::ExistentialPredicate<'tcx>>>)
-> Vec<ty::Region<'tcx>> -> Vec<ty::Region<'tcx>>
{ {
// Since we don't actually *know* the self type for an object, // Since we don't actually *know* the self type for an object,
......
...@@ -586,7 +586,7 @@ fn print<F: fmt::Write>(&self, f: &mut F, cx: &mut PrintContext) -> fmt::Result ...@@ -586,7 +586,7 @@ fn print<F: fmt::Write>(&self, f: &mut F, cx: &mut PrintContext) -> fmt::Result
} }
define_print! { define_print! {
('tcx) &'tcx ty::Slice<ty::ExistentialPredicate<'tcx>>, (self, f, cx) { ('tcx) &'tcx ty::List<ty::ExistentialPredicate<'tcx>>, (self, f, cx) {
display { display {
// Generate the main trait ref, including associated types. // Generate the main trait ref, including associated types.
ty::tls::with(|tcx| { ty::tls::with(|tcx| {
...@@ -672,7 +672,7 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ...@@ -672,7 +672,7 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
} }
define_print! { define_print! {
('tcx) &'tcx ty::Slice<Ty<'tcx>>, (self, f, cx) { ('tcx) &'tcx ty::List<Ty<'tcx>>, (self, f, cx) {
display { display {
write!(f, "{{")?; write!(f, "{{")?;
let mut tys = self.iter(); let mut tys = self.iter();
...@@ -993,7 +993,7 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ...@@ -993,7 +993,7 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
define_print_multi! { define_print_multi! {
[ [
('tcx) ty::Binder<&'tcx ty::Slice<ty::ExistentialPredicate<'tcx>>>, ('tcx) ty::Binder<&'tcx ty::List<ty::ExistentialPredicate<'tcx>>>,
('tcx) ty::Binder<ty::TraitRef<'tcx>>, ('tcx) ty::Binder<ty::TraitRef<'tcx>>,
('tcx) ty::Binder<ty::FnSig<'tcx>>, ('tcx) ty::Binder<ty::FnSig<'tcx>>,
('tcx) ty::Binder<ty::TraitPredicate<'tcx>>, ('tcx) ty::Binder<ty::TraitPredicate<'tcx>>,
......
...@@ -36,7 +36,7 @@ pub(super) fn sub_types<'tcx>( ...@@ -36,7 +36,7 @@ pub(super) fn sub_types<'tcx>(
ty::Variance::Covariant, ty::Variance::Covariant,
locations, locations,
borrowck_context, borrowck_context,
ty::Slice::empty(), ty::List::empty(),
).relate(&a, &b)?; ).relate(&a, &b)?;
Ok(()) Ok(())
} }
...@@ -54,7 +54,7 @@ pub(super) fn eq_types<'tcx>( ...@@ -54,7 +54,7 @@ pub(super) fn eq_types<'tcx>(
ty::Variance::Invariant, ty::Variance::Invariant,
locations, locations,
borrowck_context, borrowck_context,
ty::Slice::empty(), ty::List::empty(),
).relate(&a, &b)?; ).relate(&a, &b)?;
Ok(()) Ok(())
} }
......
...@@ -506,7 +506,7 @@ fn compute_inputs_and_output( ...@@ -506,7 +506,7 @@ fn compute_inputs_and_output(
&self, &self,
indices: &UniversalRegionIndices<'tcx>, indices: &UniversalRegionIndices<'tcx>,
defining_ty: DefiningTy<'tcx>, defining_ty: DefiningTy<'tcx>,
) -> ty::Binder<&'tcx ty::Slice<Ty<'tcx>>> { ) -> ty::Binder<&'tcx ty::List<Ty<'tcx>>> {
let tcx = self.infcx.tcx; let tcx = self.infcx.tcx;
match defining_ty { match defining_ty {
DefiningTy::Closure(def_id, substs) => { DefiningTy::Closure(def_id, substs) => {
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
use rustc::hir::def_id::DefId; use rustc::hir::def_id::DefId;
use rustc::middle::lang_items::LangItem; use rustc::middle::lang_items::LangItem;
use rustc::mir::*; 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 rustc_data_structures::indexed_vec::{Idx};
use transform::{MirPass, MirSource}; use transform::{MirPass, MirSource};
use syntax; use syntax;
...@@ -114,7 +114,7 @@ fn lower_128bit_ops<'a, 'tcx>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, mir: &mut Mir< ...@@ -114,7 +114,7 @@ fn lower_128bit_ops<'a, 'tcx>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, mir: &mut Mir<
source_info, source_info,
kind: TerminatorKind::Call { kind: TerminatorKind::Call {
func: Operand::function_handle(tcx, call_did, func: Operand::function_handle(tcx, call_did,
Slice::empty(), source_info.span), List::empty(), source_info.span),
args: vec![lhs, rhs], args: vec![lhs, rhs],
destination: Some((place, bb)), destination: Some((place, bb)),
cleanup: None, cleanup: None,
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
WhereClause, WhereClause,
}; };
use rustc::ty::query::Providers; use rustc::ty::query::Providers;
use rustc::ty::{self, Slice, TyCtxt}; use rustc::ty::{self, List, TyCtxt};
use rustc_data_structures::fx::FxHashSet; use rustc_data_structures::fx::FxHashSet;
use std::mem; use std::mem;
use syntax::ast; use syntax::ast;
...@@ -162,7 +162,7 @@ fn into_well_formed_goal(self) -> DomainGoal<'tcx> { ...@@ -162,7 +162,7 @@ fn into_well_formed_goal(self) -> DomainGoal<'tcx> {
DefPathData::AssocTypeInImpl(..) => program_clauses_for_associated_type_value(tcx, def_id), DefPathData::AssocTypeInImpl(..) => program_clauses_for_associated_type_value(tcx, def_id),
DefPathData::AssocTypeInTrait(..) => program_clauses_for_associated_type_def(tcx, def_id), DefPathData::AssocTypeInTrait(..) => program_clauses_for_associated_type_def(tcx, def_id),
DefPathData::TypeNs(..) => program_clauses_for_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>( ...@@ -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> { 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) { if let ImplPolarity::Negative = tcx.impl_polarity(def_id) {
return Slice::empty(); return List::empty();
} }
// Rule Implemented-From-Impl (see rustc guide) // Rule Implemented-From-Impl (see rustc guide)
......
...@@ -1666,7 +1666,7 @@ pub fn ty_of_fn(&self, ...@@ -1666,7 +1666,7 @@ pub fn ty_of_fn(&self,
/// we return `None`. /// we return `None`.
fn compute_object_lifetime_bound(&self, fn compute_object_lifetime_bound(&self,
span: Span, span: Span,
existential_predicates: ty::Binder<&'tcx ty::Slice<ty::ExistentialPredicate<'tcx>>>) existential_predicates: ty::Binder<&'tcx ty::List<ty::ExistentialPredicate<'tcx>>>)
-> Option<ty::Region<'tcx>> // if None, use the default -> Option<ty::Region<'tcx>> // if None, use the default
{ {
let tcx = self.tcx(); let tcx = self.tcx();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册