mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-11 08:05:12 +00:00
Auto merge of #26267 - eefriedman:split-tyarray, r=eddyb
Arrays and slices are closely related, but not that closely; making the separation more explicit is generally more clear.
This commit is contained in:
commit
a27982623c
@ -113,11 +113,12 @@ pub fn enc_ty<'a, 'tcx>(w: &mut Encoder, cx: &ctxt<'a, 'tcx>, t: Ty<'tcx>) {
|
|||||||
ty::TyArray(t, sz) => {
|
ty::TyArray(t, sz) => {
|
||||||
mywrite!(w, "V");
|
mywrite!(w, "V");
|
||||||
enc_ty(w, cx, t);
|
enc_ty(w, cx, t);
|
||||||
mywrite!(w, "/");
|
mywrite!(w, "/{}|", sz);
|
||||||
match sz {
|
}
|
||||||
Some(n) => mywrite!(w, "{}|", n),
|
ty::TySlice(t) => {
|
||||||
None => mywrite!(w, "|"),
|
mywrite!(w, "V");
|
||||||
}
|
enc_ty(w, cx, t);
|
||||||
|
mywrite!(w, "/|");
|
||||||
}
|
}
|
||||||
ty::TyStr => {
|
ty::TyStr => {
|
||||||
mywrite!(w, "v");
|
mywrite!(w, "v");
|
||||||
|
@ -423,7 +423,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for CheckCrateVisitor<'a, 'tcx> {
|
|||||||
self.visit_expr(&**element);
|
self.visit_expr(&**element);
|
||||||
// The count is checked elsewhere (typeck).
|
// The count is checked elsewhere (typeck).
|
||||||
let count = match node_ty.sty {
|
let count = match node_ty.sty {
|
||||||
ty::TyArray(_, Some(n)) => n,
|
ty::TyArray(_, n) => n,
|
||||||
_ => unreachable!()
|
_ => unreachable!()
|
||||||
};
|
};
|
||||||
// [element; 0] is always zero-sized.
|
// [element; 0] is always zero-sized.
|
||||||
@ -851,10 +851,14 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for CheckCrateVisitor<'a, 'tcx> {
|
|||||||
}
|
}
|
||||||
let mutbl = bk.to_mutbl_lossy();
|
let mutbl = bk.to_mutbl_lossy();
|
||||||
if mutbl == ast::MutMutable && self.mode == Mode::StaticMut {
|
if mutbl == ast::MutMutable && self.mode == Mode::StaticMut {
|
||||||
// Mutable slices are the only `&mut` allowed in globals,
|
// Mutable slices are the only `&mut` allowed in
|
||||||
// but only in `static mut`, nowhere else.
|
// globals, but only in `static mut`, nowhere else.
|
||||||
|
// FIXME: This exception is really weird... there isn't
|
||||||
|
// any fundamental reason to restrict this based on
|
||||||
|
// type of the expression. `&mut [1]` has exactly the
|
||||||
|
// same representation as &mut 1.
|
||||||
match cmt.ty.sty {
|
match cmt.ty.sty {
|
||||||
ty::TyArray(_, _) => break,
|
ty::TyArray(_, _) | ty::TySlice(_) => break,
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -537,14 +537,14 @@ fn construct_witness(cx: &MatchCheckCtxt, ctor: &Constructor,
|
|||||||
|
|
||||||
ty::TyRef(_, ty::mt { ty, mutbl }) => {
|
ty::TyRef(_, ty::mt { ty, mutbl }) => {
|
||||||
match ty.sty {
|
match ty.sty {
|
||||||
ty::TyArray(_, Some(n)) => match ctor {
|
ty::TyArray(_, n) => match ctor {
|
||||||
&Single => {
|
&Single => {
|
||||||
assert_eq!(pats_len, n);
|
assert_eq!(pats_len, n);
|
||||||
ast::PatVec(pats.collect(), None, vec!())
|
ast::PatVec(pats.collect(), None, vec!())
|
||||||
},
|
},
|
||||||
_ => unreachable!()
|
_ => unreachable!()
|
||||||
},
|
},
|
||||||
ty::TyArray(_, None) => match ctor {
|
ty::TySlice(_) => match ctor {
|
||||||
&Slice(n) => {
|
&Slice(n) => {
|
||||||
assert_eq!(pats_len, n);
|
assert_eq!(pats_len, n);
|
||||||
ast::PatVec(pats.collect(), None, vec!())
|
ast::PatVec(pats.collect(), None, vec!())
|
||||||
@ -560,7 +560,7 @@ fn construct_witness(cx: &MatchCheckCtxt, ctor: &Constructor,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ty::TyArray(_, Some(len)) => {
|
ty::TyArray(_, len) => {
|
||||||
assert_eq!(pats_len, len);
|
assert_eq!(pats_len, len);
|
||||||
ast::PatVec(pats.collect(), None, vec![])
|
ast::PatVec(pats.collect(), None, vec![])
|
||||||
}
|
}
|
||||||
@ -601,7 +601,7 @@ fn all_constructors(cx: &MatchCheckCtxt, left_ty: Ty,
|
|||||||
[true, false].iter().map(|b| ConstantValue(const_bool(*b))).collect(),
|
[true, false].iter().map(|b| ConstantValue(const_bool(*b))).collect(),
|
||||||
|
|
||||||
ty::TyRef(_, ty::mt { ty, .. }) => match ty.sty {
|
ty::TyRef(_, ty::mt { ty, .. }) => match ty.sty {
|
||||||
ty::TyArray(_, None) =>
|
ty::TySlice(_) =>
|
||||||
range_inclusive(0, max_slice_length).map(|length| Slice(length)).collect(),
|
range_inclusive(0, max_slice_length).map(|length| Slice(length)).collect(),
|
||||||
_ => vec!(Single)
|
_ => vec!(Single)
|
||||||
},
|
},
|
||||||
@ -779,7 +779,7 @@ fn pat_constructors(cx: &MatchCheckCtxt, p: &Pat,
|
|||||||
vec!(ConstantRange(eval_const_expr(cx.tcx, &**lo), eval_const_expr(cx.tcx, &**hi))),
|
vec!(ConstantRange(eval_const_expr(cx.tcx, &**lo), eval_const_expr(cx.tcx, &**hi))),
|
||||||
ast::PatVec(ref before, ref slice, ref after) =>
|
ast::PatVec(ref before, ref slice, ref after) =>
|
||||||
match left_ty.sty {
|
match left_ty.sty {
|
||||||
ty::TyArray(_, Some(_)) => vec!(Single),
|
ty::TyArray(_, _) => vec!(Single),
|
||||||
_ => if slice.is_some() {
|
_ => if slice.is_some() {
|
||||||
range_inclusive(before.len() + after.len(), max_slice_length)
|
range_inclusive(before.len() + after.len(), max_slice_length)
|
||||||
.map(|length| Slice(length))
|
.map(|length| Slice(length))
|
||||||
@ -807,7 +807,7 @@ pub fn constructor_arity(cx: &MatchCheckCtxt, ctor: &Constructor, ty: Ty) -> usi
|
|||||||
ty::TyTuple(ref fs) => fs.len(),
|
ty::TyTuple(ref fs) => fs.len(),
|
||||||
ty::TyBox(_) => 1,
|
ty::TyBox(_) => 1,
|
||||||
ty::TyRef(_, ty::mt { ty, .. }) => match ty.sty {
|
ty::TyRef(_, ty::mt { ty, .. }) => match ty.sty {
|
||||||
ty::TyArray(_, None) => match *ctor {
|
ty::TySlice(_) => match *ctor {
|
||||||
Slice(length) => length,
|
Slice(length) => length,
|
||||||
ConstantValue(_) => 0,
|
ConstantValue(_) => 0,
|
||||||
_ => unreachable!()
|
_ => unreachable!()
|
||||||
@ -822,7 +822,7 @@ pub fn constructor_arity(cx: &MatchCheckCtxt, ctor: &Constructor, ty: Ty) -> usi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
ty::TyStruct(cid, _) => ty::lookup_struct_fields(cx.tcx, cid).len(),
|
ty::TyStruct(cid, _) => ty::lookup_struct_fields(cx.tcx, cid).len(),
|
||||||
ty::TyArray(_, Some(n)) => n,
|
ty::TyArray(_, n) => n,
|
||||||
_ => 0
|
_ => 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ pub fn simplify_type(tcx: &ty::ctxt,
|
|||||||
ty::TyFloat(float_type) => Some(FloatSimplifiedType(float_type)),
|
ty::TyFloat(float_type) => Some(FloatSimplifiedType(float_type)),
|
||||||
ty::TyEnum(def_id, _) => Some(EnumSimplifiedType(def_id)),
|
ty::TyEnum(def_id, _) => Some(EnumSimplifiedType(def_id)),
|
||||||
ty::TyStr => Some(StrSimplifiedType),
|
ty::TyStr => Some(StrSimplifiedType),
|
||||||
ty::TyArray(..) => Some(VecSimplifiedType),
|
ty::TyArray(..) | ty::TySlice(_) => Some(VecSimplifiedType),
|
||||||
ty::TyRawPtr(_) => Some(PtrSimplifiedType),
|
ty::TyRawPtr(_) => Some(PtrSimplifiedType),
|
||||||
ty::TyTrait(ref trait_info) => {
|
ty::TyTrait(ref trait_info) => {
|
||||||
Some(TraitSimplifiedType(trait_info.principal_def_id()))
|
Some(TraitSimplifiedType(trait_info.principal_def_id()))
|
||||||
|
@ -117,6 +117,7 @@ impl<'a, 'tcx> Implicator<'a, 'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ty::TyArray(t, _) |
|
ty::TyArray(t, _) |
|
||||||
|
ty::TySlice(t) |
|
||||||
ty::TyRawPtr(ty::mt { ty: t, .. }) |
|
ty::TyRawPtr(ty::mt { ty: t, .. }) |
|
||||||
ty::TyBox(t) => {
|
ty::TyBox(t) => {
|
||||||
self.accumulate_from_ty(t)
|
self.accumulate_from_ty(t)
|
||||||
|
@ -159,6 +159,7 @@ impl<'a, 'tcx> TypeFolder<'tcx> for TypeFreshener<'a, 'tcx> {
|
|||||||
ty::TyStr |
|
ty::TyStr |
|
||||||
ty::TyError |
|
ty::TyError |
|
||||||
ty::TyArray(..) |
|
ty::TyArray(..) |
|
||||||
|
ty::TySlice(..) |
|
||||||
ty::TyRawPtr(..) |
|
ty::TyRawPtr(..) |
|
||||||
ty::TyRef(..) |
|
ty::TyRef(..) |
|
||||||
ty::TyBareFn(..) |
|
ty::TyBareFn(..) |
|
||||||
|
@ -230,7 +230,7 @@ fn deref_kind(t: Ty, context: DerefKindContext) -> McResult<deref_kind> {
|
|||||||
Ok(deref_interior(InteriorField(PositionalField(0))))
|
Ok(deref_interior(InteriorField(PositionalField(0))))
|
||||||
}
|
}
|
||||||
|
|
||||||
ty::TyArray(_, _) | ty::TyStr => {
|
ty::TyArray(_, _) | ty::TySlice(_) | ty::TyStr => {
|
||||||
// no deref of indexed content without supplying InteriorOffsetKind
|
// no deref of indexed content without supplying InteriorOffsetKind
|
||||||
if let Some(context) = context {
|
if let Some(context) = context {
|
||||||
Ok(deref_interior(InteriorElement(context, element_kind(t))))
|
Ok(deref_interior(InteriorElement(context, element_kind(t))))
|
||||||
@ -843,7 +843,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
|
|||||||
// Only promote `[T; 0]` before an RFC for rvalue promotions
|
// Only promote `[T; 0]` before an RFC for rvalue promotions
|
||||||
// is accepted.
|
// is accepted.
|
||||||
let qualif = match expr_ty.sty {
|
let qualif = match expr_ty.sty {
|
||||||
ty::TyArray(_, Some(0)) => qualif,
|
ty::TyArray(_, 0) => qualif,
|
||||||
_ => check_const::ConstQualif::NOT_CONST
|
_ => check_const::ConstQualif::NOT_CONST
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1130,7 +1130,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
|
|||||||
-> (ast::Mutability, ty::Region) {
|
-> (ast::Mutability, ty::Region) {
|
||||||
match slice_ty.sty {
|
match slice_ty.sty {
|
||||||
ty::TyRef(r, ref mt) => match mt.ty.sty {
|
ty::TyRef(r, ref mt) => match mt.ty.sty {
|
||||||
ty::TyArray(_, None) => (mt.mutbl, *r),
|
ty::TySlice(_) => (mt.mutbl, *r),
|
||||||
_ => vec_slice_info(tcx, pat, mt.ty),
|
_ => vec_slice_info(tcx, pat, mt.ty),
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -1669,10 +1669,10 @@ fn element_kind(t: Ty) -> ElementKind {
|
|||||||
match t.sty {
|
match t.sty {
|
||||||
ty::TyRef(_, ty::mt{ty, ..}) |
|
ty::TyRef(_, ty::mt{ty, ..}) |
|
||||||
ty::TyBox(ty) => match ty.sty {
|
ty::TyBox(ty) => match ty.sty {
|
||||||
ty::TyArray(_, None) => VecElement,
|
ty::TySlice(_) => VecElement,
|
||||||
_ => OtherElement
|
_ => OtherElement
|
||||||
},
|
},
|
||||||
ty::TyArray(..) => VecElement,
|
ty::TyArray(..) | ty::TySlice(_) => VecElement,
|
||||||
_ => OtherElement
|
_ => OtherElement
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -306,6 +306,7 @@ fn ty_is_local_constructor<'tcx>(tcx: &ty::ctxt<'tcx>,
|
|||||||
ty::TyStr(..) |
|
ty::TyStr(..) |
|
||||||
ty::TyBareFn(..) |
|
ty::TyBareFn(..) |
|
||||||
ty::TyArray(..) |
|
ty::TyArray(..) |
|
||||||
|
ty::TySlice(..) |
|
||||||
ty::TyRawPtr(..) |
|
ty::TyRawPtr(..) |
|
||||||
ty::TyRef(..) |
|
ty::TyRef(..) |
|
||||||
ty::TyTuple(..) |
|
ty::TyTuple(..) |
|
||||||
|
@ -1429,7 +1429,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// [T; n] -> [T].
|
// [T; n] -> [T].
|
||||||
(&ty::TyArray(_, Some(_)), &ty::TyArray(_, None)) => true,
|
(&ty::TyArray(_, _), &ty::TySlice(_)) => true,
|
||||||
|
|
||||||
// Struct<T> -> Struct<U>.
|
// Struct<T> -> Struct<U>.
|
||||||
(&ty::TyStruct(def_id_a, _), &ty::TyStruct(def_id_b, _)) => {
|
(&ty::TyStruct(def_id_a, _), &ty::TyStruct(def_id_b, _)) => {
|
||||||
@ -1662,35 +1662,18 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ty::TyArray(element_ty, ref len) => {
|
ty::TyArray(element_ty, _) => {
|
||||||
// [T; n] and [T]
|
// [T; n]
|
||||||
match bound {
|
match bound {
|
||||||
ty::BoundCopy => {
|
ty::BoundCopy => ok_if(vec![element_ty]),
|
||||||
match *len {
|
ty::BoundSized => ok_if(Vec::new()),
|
||||||
// [T; n] is copy iff T is copy
|
|
||||||
Some(_) => ok_if(vec![element_ty]),
|
|
||||||
|
|
||||||
// [T] is unsized and hence affine
|
|
||||||
None => Err(Unimplemented),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ty::BoundSized => {
|
|
||||||
if len.is_some() {
|
|
||||||
ok_if(Vec::new())
|
|
||||||
} else {
|
|
||||||
Err(Unimplemented)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ty::BoundSync | ty::BoundSend => {
|
ty::BoundSync | ty::BoundSend => {
|
||||||
self.tcx().sess.bug("Send/Sync shouldn't occur in builtin_bounds()");
|
self.tcx().sess.bug("Send/Sync shouldn't occur in builtin_bounds()");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ty::TyStr => {
|
ty::TyStr | ty::TySlice(_) => {
|
||||||
// Equivalent to [u8]
|
|
||||||
match bound {
|
match bound {
|
||||||
ty::BoundSync | ty::BoundSend => {
|
ty::BoundSync | ty::BoundSend => {
|
||||||
self.tcx().sess.bug("Send/Sync shouldn't occur in builtin_bounds()");
|
self.tcx().sess.bug("Send/Sync shouldn't occur in builtin_bounds()");
|
||||||
@ -1855,7 +1838,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||||||
Some(vec![element_ty])
|
Some(vec![element_ty])
|
||||||
},
|
},
|
||||||
|
|
||||||
ty::TyArray(element_ty, _) => {
|
ty::TyArray(element_ty, _) | ty::TySlice(element_ty) => {
|
||||||
Some(vec![element_ty])
|
Some(vec![element_ty])
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2510,7 +2493,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// [T; n] -> [T].
|
// [T; n] -> [T].
|
||||||
(&ty::TyArray(a, Some(_)), &ty::TyArray(b, None)) => {
|
(&ty::TyArray(a, _), &ty::TySlice(b)) => {
|
||||||
let origin = infer::Misc(obligation.cause.span);
|
let origin = infer::Misc(obligation.cause.span);
|
||||||
if self.infcx.sub_types(false, origin, a, b).is_err() {
|
if self.infcx.sub_types(false, origin, a, b).is_err() {
|
||||||
return Err(Unimplemented);
|
return Err(Unimplemented);
|
||||||
|
@ -906,7 +906,7 @@ impl<'tcx> ctxt<'tcx> {
|
|||||||
pub fn print_debug_stats(&self) {
|
pub fn print_debug_stats(&self) {
|
||||||
sty_debug_print!(
|
sty_debug_print!(
|
||||||
self,
|
self,
|
||||||
TyEnum, TyBox, TyArray, TyRawPtr, TyRef, TyBareFn, TyTrait,
|
TyEnum, TyBox, TyArray, TySlice, TyRawPtr, TyRef, TyBareFn, TyTrait,
|
||||||
TyStruct, TyClosure, TyTuple, TyParam, TyInfer, TyProjection);
|
TyStruct, TyClosure, TyTuple, TyParam, TyInfer, TyProjection);
|
||||||
|
|
||||||
println!("Substs interner: #{}", self.substs_interner.borrow().len());
|
println!("Substs interner: #{}", self.substs_interner.borrow().len());
|
||||||
@ -1378,10 +1378,11 @@ pub enum TypeVariants<'tcx> {
|
|||||||
/// The pointee of a string slice. Written as `str`.
|
/// The pointee of a string slice. Written as `str`.
|
||||||
TyStr,
|
TyStr,
|
||||||
|
|
||||||
/// An array with the given length, or the pointee
|
/// An array with the given length. Written as `[T; n]`.
|
||||||
/// of an array slice. Written as `[T; n]`, or `[T]`.
|
TyArray(Ty<'tcx>, usize),
|
||||||
/// FIXME: It probably makes sense to separate these.
|
|
||||||
TyArray(Ty<'tcx>, Option<usize>),
|
/// The pointee of an array slice. Written as `[T]`.
|
||||||
|
TySlice(Ty<'tcx>),
|
||||||
|
|
||||||
/// A raw pointer. Written as `*mut T` or `*const T`
|
/// A raw pointer. Written as `*mut T` or `*const T`
|
||||||
TyRawPtr(mt<'tcx>),
|
TyRawPtr(mt<'tcx>),
|
||||||
@ -3047,7 +3048,7 @@ impl FlagComputation {
|
|||||||
self.add_bounds(bounds);
|
self.add_bounds(bounds);
|
||||||
}
|
}
|
||||||
|
|
||||||
&TyBox(tt) | &TyArray(tt, _) => {
|
&TyBox(tt) | &TyArray(tt, _) | &TySlice(tt) => {
|
||||||
self.add_ty(tt)
|
self.add_ty(tt)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3201,7 +3202,10 @@ pub fn mk_nil_ptr<'tcx>(cx: &ctxt<'tcx>) -> Ty<'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn mk_vec<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>, sz: Option<usize>) -> Ty<'tcx> {
|
pub fn mk_vec<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>, sz: Option<usize>) -> Ty<'tcx> {
|
||||||
mk_t(cx, TyArray(ty, sz))
|
match sz {
|
||||||
|
Some(n) => mk_t(cx, TyArray(ty, n)),
|
||||||
|
None => mk_t(cx, TySlice(ty))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn mk_slice<'tcx>(cx: &ctxt<'tcx>, r: &'tcx Region, tm: mt<'tcx>) -> Ty<'tcx> {
|
pub fn mk_slice<'tcx>(cx: &ctxt<'tcx>, r: &'tcx Region, tm: mt<'tcx>) -> Ty<'tcx> {
|
||||||
@ -3480,29 +3484,17 @@ pub fn type_is_self(ty: Ty) -> bool {
|
|||||||
fn type_is_slice(ty: Ty) -> bool {
|
fn type_is_slice(ty: Ty) -> bool {
|
||||||
match ty.sty {
|
match ty.sty {
|
||||||
TyRawPtr(mt) | TyRef(_, mt) => match mt.ty.sty {
|
TyRawPtr(mt) | TyRef(_, mt) => match mt.ty.sty {
|
||||||
TyArray(_, None) | TyStr => true,
|
TySlice(_) | TyStr => true,
|
||||||
_ => false,
|
_ => false,
|
||||||
},
|
},
|
||||||
_ => false
|
_ => false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn type_is_vec(ty: Ty) -> bool {
|
|
||||||
match ty.sty {
|
|
||||||
TyArray(..) => true,
|
|
||||||
TyRawPtr(mt{ty, ..}) | TyRef(_, mt{ty, ..}) |
|
|
||||||
TyBox(ty) => match ty.sty {
|
|
||||||
TyArray(_, None) => true,
|
|
||||||
_ => false
|
|
||||||
},
|
|
||||||
_ => false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn type_is_structural(ty: Ty) -> bool {
|
pub fn type_is_structural(ty: Ty) -> bool {
|
||||||
match ty.sty {
|
match ty.sty {
|
||||||
TyStruct(..) | TyTuple(_) | TyEnum(..) |
|
TyStruct(..) | TyTuple(_) | TyEnum(..) |
|
||||||
TyArray(_, Some(_)) | TyClosure(..) => true,
|
TyArray(..) | TyClosure(..) => true,
|
||||||
_ => type_is_slice(ty) | type_is_trait(ty)
|
_ => type_is_slice(ty) | type_is_trait(ty)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3516,7 +3508,7 @@ pub fn type_is_simd(cx: &ctxt, ty: Ty) -> bool {
|
|||||||
|
|
||||||
pub fn sequence_element_type<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx> {
|
pub fn sequence_element_type<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx> {
|
||||||
match ty.sty {
|
match ty.sty {
|
||||||
TyArray(ty, _) => ty,
|
TyArray(ty, _) | TySlice(ty) => ty,
|
||||||
TyStr => mk_mach_uint(cx, ast::TyU8),
|
TyStr => mk_mach_uint(cx, ast::TyU8),
|
||||||
_ => cx.sess.bug(&format!("sequence_element_type called on non-sequence value: {}",
|
_ => cx.sess.bug(&format!("sequence_element_type called on non-sequence value: {}",
|
||||||
ty_to_string(cx, ty))),
|
ty_to_string(cx, ty))),
|
||||||
@ -3816,17 +3808,18 @@ pub fn type_contents<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> TypeContents {
|
|||||||
TyRef(r, ref mt) => {
|
TyRef(r, ref mt) => {
|
||||||
TC::ReachesFfiUnsafe | match mt.ty.sty {
|
TC::ReachesFfiUnsafe | match mt.ty.sty {
|
||||||
TyStr => borrowed_contents(*r, ast::MutImmutable),
|
TyStr => borrowed_contents(*r, ast::MutImmutable),
|
||||||
TyArray(..) => tc_ty(cx, mt.ty, cache).reference(borrowed_contents(*r,
|
TyArray(..) |
|
||||||
|
TySlice(_) => tc_ty(cx, mt.ty, cache).reference(borrowed_contents(*r,
|
||||||
mt.mutbl)),
|
mt.mutbl)),
|
||||||
_ => tc_ty(cx, mt.ty, cache).reference(borrowed_contents(*r, mt.mutbl)),
|
_ => tc_ty(cx, mt.ty, cache).reference(borrowed_contents(*r, mt.mutbl)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TyArray(ty, Some(_)) => {
|
TyArray(ty, _) => {
|
||||||
tc_ty(cx, ty, cache)
|
tc_ty(cx, ty, cache)
|
||||||
}
|
}
|
||||||
|
|
||||||
TyArray(ty, None) => {
|
TySlice(ty) => {
|
||||||
tc_ty(cx, ty, cache) | TC::Nonsized
|
tc_ty(cx, ty, cache) | TC::Nonsized
|
||||||
}
|
}
|
||||||
TyStr => TC::Nonsized,
|
TyStr => TC::Nonsized,
|
||||||
@ -4021,7 +4014,7 @@ pub fn type_moves_by_default<'a,'tcx>(param_env: &ParameterEnvironment<'a,'tcx>,
|
|||||||
mutbl: ast::MutMutable, ..
|
mutbl: ast::MutMutable, ..
|
||||||
}) => Some(true),
|
}) => Some(true),
|
||||||
|
|
||||||
TyArray(..) | TyTrait(..) | TyTuple(..) |
|
TyArray(..) | TySlice(_) | TyTrait(..) | TyTuple(..) |
|
||||||
TyClosure(..) | TyEnum(..) | TyStruct(..) |
|
TyClosure(..) | TyEnum(..) | TyStruct(..) |
|
||||||
TyProjection(..) | TyParam(..) | TyInfer(..) | TyError => None
|
TyProjection(..) | TyParam(..) | TyInfer(..) | TyError => None
|
||||||
}.unwrap_or_else(|| !type_impls_bound(Some(param_env),
|
}.unwrap_or_else(|| !type_impls_bound(Some(param_env),
|
||||||
@ -4066,9 +4059,9 @@ fn type_is_sized_uncached<'a,'tcx>(param_env: Option<&ParameterEnvironment<'a,'t
|
|||||||
let result = match ty.sty {
|
let result = match ty.sty {
|
||||||
TyBool | TyChar | TyInt(..) | TyUint(..) | TyFloat(..) |
|
TyBool | TyChar | TyInt(..) | TyUint(..) | TyFloat(..) |
|
||||||
TyBox(..) | TyRawPtr(..) | TyRef(..) | TyBareFn(..) |
|
TyBox(..) | TyRawPtr(..) | TyRef(..) | TyBareFn(..) |
|
||||||
TyArray(_, Some(..)) | TyTuple(..) | TyClosure(..) => Some(true),
|
TyArray(..) | TyTuple(..) | TyClosure(..) => Some(true),
|
||||||
|
|
||||||
TyStr | TyTrait(..) | TyArray(_, None) => Some(false),
|
TyStr | TyTrait(..) | TySlice(_) => Some(false),
|
||||||
|
|
||||||
TyEnum(..) | TyStruct(..) | TyProjection(..) | TyParam(..) |
|
TyEnum(..) | TyStruct(..) | TyProjection(..) | TyParam(..) |
|
||||||
TyInfer(..) | TyError => None
|
TyInfer(..) | TyError => None
|
||||||
@ -4116,8 +4109,8 @@ pub fn is_instantiable<'tcx>(cx: &ctxt<'tcx>, r_ty: Ty<'tcx>) -> bool {
|
|||||||
// fixed length vectors need special treatment compared to
|
// fixed length vectors need special treatment compared to
|
||||||
// normal vectors, since they don't necessarily have the
|
// normal vectors, since they don't necessarily have the
|
||||||
// possibility to have length zero.
|
// possibility to have length zero.
|
||||||
TyArray(_, Some(0)) => false, // don't need no contents
|
TyArray(_, 0) => false, // don't need no contents
|
||||||
TyArray(ty, Some(_)) => type_requires(cx, seen, r_ty, ty),
|
TyArray(ty, _) => type_requires(cx, seen, r_ty, ty),
|
||||||
|
|
||||||
TyBool |
|
TyBool |
|
||||||
TyChar |
|
TyChar |
|
||||||
@ -4128,7 +4121,7 @@ pub fn is_instantiable<'tcx>(cx: &ctxt<'tcx>, r_ty: Ty<'tcx>) -> bool {
|
|||||||
TyBareFn(..) |
|
TyBareFn(..) |
|
||||||
TyParam(_) |
|
TyParam(_) |
|
||||||
TyProjection(_) |
|
TyProjection(_) |
|
||||||
TyArray(_, None) => {
|
TySlice(_) => {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
TyBox(typ) => {
|
TyBox(typ) => {
|
||||||
@ -4238,7 +4231,7 @@ pub fn is_type_representable<'tcx>(cx: &ctxt<'tcx>, sp: Span, ty: Ty<'tcx>)
|
|||||||
}
|
}
|
||||||
// Fixed-length vectors.
|
// Fixed-length vectors.
|
||||||
// FIXME(#11924) Behavior undecided for zero-length vectors.
|
// FIXME(#11924) Behavior undecided for zero-length vectors.
|
||||||
TyArray(ty, Some(_)) => {
|
TyArray(ty, _) => {
|
||||||
is_type_structurally_recursive(cx, sp, seen, ty)
|
is_type_structurally_recursive(cx, sp, seen, ty)
|
||||||
}
|
}
|
||||||
TyStruct(did, substs) => {
|
TyStruct(did, substs) => {
|
||||||
@ -4494,7 +4487,7 @@ pub fn type_content<'tcx>(ty: Ty<'tcx>) -> Ty<'tcx> {
|
|||||||
// Returns the type of ty[i]
|
// Returns the type of ty[i]
|
||||||
pub fn index<'tcx>(ty: Ty<'tcx>) -> Option<Ty<'tcx>> {
|
pub fn index<'tcx>(ty: Ty<'tcx>) -> Option<Ty<'tcx>> {
|
||||||
match ty.sty {
|
match ty.sty {
|
||||||
TyArray(ty, _) => Some(ty),
|
TyArray(ty, _) | TySlice(ty) => Some(ty),
|
||||||
_ => None
|
_ => None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4504,7 +4497,7 @@ pub fn index<'tcx>(ty: Ty<'tcx>) -> Option<Ty<'tcx>> {
|
|||||||
// which can't actually be indexed.
|
// which can't actually be indexed.
|
||||||
pub fn array_element_ty<'tcx>(tcx: &ctxt<'tcx>, ty: Ty<'tcx>) -> Option<Ty<'tcx>> {
|
pub fn array_element_ty<'tcx>(tcx: &ctxt<'tcx>, ty: Ty<'tcx>) -> Option<Ty<'tcx>> {
|
||||||
match ty.sty {
|
match ty.sty {
|
||||||
TyArray(ty, _) => Some(ty),
|
TyArray(ty, _) | TySlice(ty) => Some(ty),
|
||||||
TyStr => Some(tcx.types.u8),
|
TyStr => Some(tcx.types.u8),
|
||||||
_ => None
|
_ => None
|
||||||
}
|
}
|
||||||
@ -5063,8 +5056,8 @@ pub fn ty_sort_string<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> String {
|
|||||||
|
|
||||||
TyEnum(id, _) => format!("enum `{}`", item_path_str(cx, id)),
|
TyEnum(id, _) => format!("enum `{}`", item_path_str(cx, id)),
|
||||||
TyBox(_) => "box".to_string(),
|
TyBox(_) => "box".to_string(),
|
||||||
TyArray(_, Some(n)) => format!("array of {} elements", n),
|
TyArray(_, n) => format!("array of {} elements", n),
|
||||||
TyArray(_, None) => "slice".to_string(),
|
TySlice(_) => "slice".to_string(),
|
||||||
TyRawPtr(_) => "*-ptr".to_string(),
|
TyRawPtr(_) => "*-ptr".to_string(),
|
||||||
TyRef(_, _) => "&-ptr".to_string(),
|
TyRef(_, _) => "&-ptr".to_string(),
|
||||||
TyBareFn(Some(_), _) => format!("fn item"),
|
TyBareFn(Some(_), _) => format!("fn item"),
|
||||||
@ -6626,11 +6619,11 @@ pub fn hash_crate_independent<'tcx>(tcx: &ctxt<'tcx>, ty: Ty<'tcx>, svh: &Svh) -
|
|||||||
TyBox(_) => {
|
TyBox(_) => {
|
||||||
byte!(9);
|
byte!(9);
|
||||||
}
|
}
|
||||||
TyArray(_, Some(n)) => {
|
TyArray(_, n) => {
|
||||||
byte!(10);
|
byte!(10);
|
||||||
n.hash(state);
|
n.hash(state);
|
||||||
}
|
}
|
||||||
TyArray(_, None) => {
|
TySlice(_) => {
|
||||||
byte!(11);
|
byte!(11);
|
||||||
}
|
}
|
||||||
TyRawPtr(m) => {
|
TyRawPtr(m) => {
|
||||||
@ -6967,6 +6960,7 @@ pub fn accumulate_lifetimes_in_type(accumulator: &mut Vec<ty::Region>,
|
|||||||
TyBox(_) |
|
TyBox(_) |
|
||||||
TyStr |
|
TyStr |
|
||||||
TyArray(_, _) |
|
TyArray(_, _) |
|
||||||
|
TySlice(_) |
|
||||||
TyRawPtr(_) |
|
TyRawPtr(_) |
|
||||||
TyBareFn(..) |
|
TyBareFn(..) |
|
||||||
TyTuple(_) |
|
TyTuple(_) |
|
||||||
|
@ -599,6 +599,9 @@ pub fn super_fold_ty<'tcx, T: TypeFolder<'tcx>>(this: &mut T,
|
|||||||
ty::TyArray(typ, sz) => {
|
ty::TyArray(typ, sz) => {
|
||||||
ty::TyArray(typ.fold_with(this), sz)
|
ty::TyArray(typ.fold_with(this), sz)
|
||||||
}
|
}
|
||||||
|
ty::TySlice(typ) => {
|
||||||
|
ty::TySlice(typ.fold_with(this))
|
||||||
|
}
|
||||||
ty::TyEnum(tid, ref substs) => {
|
ty::TyEnum(tid, ref substs) => {
|
||||||
let substs = substs.fold_with(this);
|
let substs = substs.fold_with(this);
|
||||||
ty::TyEnum(tid, this.tcx().mk_substs(substs))
|
ty::TyEnum(tid, this.tcx().mk_substs(substs))
|
||||||
|
@ -518,7 +518,7 @@ pub fn super_relate_tys<'a,'tcx:'a,R>(relation: &mut R,
|
|||||||
Ok(ty::mk_rptr(tcx, tcx.mk_region(r), mt))
|
Ok(ty::mk_rptr(tcx, tcx.mk_region(r), mt))
|
||||||
}
|
}
|
||||||
|
|
||||||
(&ty::TyArray(a_t, Some(sz_a)), &ty::TyArray(b_t, Some(sz_b))) =>
|
(&ty::TyArray(a_t, sz_a), &ty::TyArray(b_t, sz_b)) =>
|
||||||
{
|
{
|
||||||
let t = try!(relation.relate(&a_t, &b_t));
|
let t = try!(relation.relate(&a_t, &b_t));
|
||||||
if sz_a == sz_b {
|
if sz_a == sz_b {
|
||||||
@ -528,7 +528,7 @@ pub fn super_relate_tys<'a,'tcx:'a,R>(relation: &mut R,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
(&ty::TyArray(a_t, None), &ty::TyArray(b_t, None)) =>
|
(&ty::TySlice(a_t), &ty::TySlice(b_t)) =>
|
||||||
{
|
{
|
||||||
let t = try!(relation.relate(&a_t, &b_t));
|
let t = try!(relation.relate(&a_t, &b_t));
|
||||||
Ok(ty::mk_vec(tcx, t, None))
|
Ok(ty::mk_vec(tcx, t, None))
|
||||||
|
@ -71,7 +71,7 @@ fn push_subtypes<'tcx>(stack: &mut Vec<Ty<'tcx>>, parent_ty: Ty<'tcx>) {
|
|||||||
ty::TyBool | ty::TyChar | ty::TyInt(_) | ty::TyUint(_) | ty::TyFloat(_) |
|
ty::TyBool | ty::TyChar | ty::TyInt(_) | ty::TyUint(_) | ty::TyFloat(_) |
|
||||||
ty::TyStr | ty::TyInfer(_) | ty::TyParam(_) | ty::TyError => {
|
ty::TyStr | ty::TyInfer(_) | ty::TyParam(_) | ty::TyError => {
|
||||||
}
|
}
|
||||||
ty::TyBox(ty) | ty::TyArray(ty, _) => {
|
ty::TyBox(ty) | ty::TyArray(ty, _) | ty::TySlice(ty) => {
|
||||||
stack.push(ty);
|
stack.push(ty);
|
||||||
}
|
}
|
||||||
ty::TyRawPtr(ref mt) | ty::TyRef(_, ref mt) => {
|
ty::TyRawPtr(ref mt) | ty::TyRef(_, ref mt) => {
|
||||||
|
@ -20,7 +20,7 @@ use middle::ty::{ReFree, ReScope, ReInfer, ReStatic, Region, ReEmpty};
|
|||||||
use middle::ty::{ReSkolemized, ReVar, BrEnv};
|
use middle::ty::{ReSkolemized, ReVar, BrEnv};
|
||||||
use middle::ty::{mt, Ty, ParamTy};
|
use middle::ty::{mt, Ty, ParamTy};
|
||||||
use middle::ty::{TyBool, TyChar, TyStruct, TyEnum};
|
use middle::ty::{TyBool, TyChar, TyStruct, TyEnum};
|
||||||
use middle::ty::{TyError, TyStr, TyArray, TyFloat, TyBareFn};
|
use middle::ty::{TyError, TyStr, TyArray, TySlice, TyFloat, TyBareFn};
|
||||||
use middle::ty::{TyParam, TyRawPtr, TyRef, TyTuple};
|
use middle::ty::{TyParam, TyRawPtr, TyRef, TyTuple};
|
||||||
use middle::ty::TyClosure;
|
use middle::ty::TyClosure;
|
||||||
use middle::ty::{TyBox, TyTrait, TyInt, TyUint, TyInfer};
|
use middle::ty::{TyBox, TyTrait, TyInt, TyUint, TyInfer};
|
||||||
@ -432,11 +432,10 @@ pub fn ty_to_string<'tcx>(cx: &ctxt<'tcx>, typ: &ty::TyS<'tcx>) -> String {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
TyArray(t, sz) => {
|
TyArray(t, sz) => {
|
||||||
let inner_str = ty_to_string(cx, t);
|
format!("[{}; {}]", ty_to_string(cx, t), sz)
|
||||||
match sz {
|
}
|
||||||
Some(n) => format!("[{}; {}]", inner_str, n),
|
TySlice(t) => {
|
||||||
None => format!("[{}]", inner_str),
|
format!("[{}]", ty_to_string(cx, t))
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -852,7 +852,7 @@ fn compare_values<'blk, 'tcx>(cx: Block<'blk, 'tcx>,
|
|||||||
match rhs_t.sty {
|
match rhs_t.sty {
|
||||||
ty::TyRef(_, mt) => match mt.ty.sty {
|
ty::TyRef(_, mt) => match mt.ty.sty {
|
||||||
ty::TyStr => compare_str(cx, lhs, rhs, rhs_t, debug_loc),
|
ty::TyStr => compare_str(cx, lhs, rhs, rhs_t, debug_loc),
|
||||||
ty::TyArray(ty, _) => match ty.sty {
|
ty::TyArray(ty, _) | ty::TySlice(ty) => match ty.sty {
|
||||||
ty::TyUint(ast::TyU8) => {
|
ty::TyUint(ast::TyU8) => {
|
||||||
// NOTE: cast &[u8] and &[u8; N] to &str and abuse the str_eq lang item,
|
// NOTE: cast &[u8] and &[u8; N] to &str and abuse the str_eq lang item,
|
||||||
// which calls memcmp().
|
// which calls memcmp().
|
||||||
@ -1116,7 +1116,7 @@ fn compile_submatch_continue<'a, 'p, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
|
|||||||
Some(vec!(Load(bcx, val)))
|
Some(vec!(Load(bcx, val)))
|
||||||
} else {
|
} else {
|
||||||
match left_ty.sty {
|
match left_ty.sty {
|
||||||
ty::TyArray(_, Some(n)) => {
|
ty::TyArray(_, n) => {
|
||||||
let args = extract_vec_elems(bcx, left_ty, n, 0, val);
|
let args = extract_vec_elems(bcx, left_ty, n, 0, val);
|
||||||
Some(args.vals)
|
Some(args.vals)
|
||||||
}
|
}
|
||||||
|
@ -472,7 +472,7 @@ fn find_discr_field_candidate<'tcx>(tcx: &ty::ctxt<'tcx>,
|
|||||||
|
|
||||||
// Is this a fixed-size array of something non-zero
|
// Is this a fixed-size array of something non-zero
|
||||||
// with at least one element?
|
// with at least one element?
|
||||||
ty::TyArray(ety, Some(d)) if d > 0 => {
|
ty::TyArray(ety, d) if d > 0 => {
|
||||||
if let Some(mut vpath) = find_discr_field_candidate(tcx, ety, path) {
|
if let Some(mut vpath) = find_discr_field_candidate(tcx, ety, path) {
|
||||||
vpath.push(0);
|
vpath.push(0);
|
||||||
Some(vpath)
|
Some(vpath)
|
||||||
|
@ -444,12 +444,12 @@ pub fn iter_structural_ty<'blk, 'tcx, F>(cx: Block<'blk, 'tcx>,
|
|||||||
cx = f(cx, llupvar, upvar.ty);
|
cx = f(cx, llupvar, upvar.ty);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ty::TyArray(_, Some(n)) => {
|
ty::TyArray(_, n) => {
|
||||||
let (base, len) = tvec::get_fixed_base_and_len(cx, data_ptr, n);
|
let (base, len) = tvec::get_fixed_base_and_len(cx, data_ptr, n);
|
||||||
let unit_ty = ty::sequence_element_type(cx.tcx(), t);
|
let unit_ty = ty::sequence_element_type(cx.tcx(), t);
|
||||||
cx = tvec::iter_vec_raw(cx, base, unit_ty, len, f);
|
cx = tvec::iter_vec_raw(cx, base, unit_ty, len, f);
|
||||||
}
|
}
|
||||||
ty::TyArray(_, None) | ty::TyStr => {
|
ty::TySlice(_) | ty::TyStr => {
|
||||||
let unit_ty = ty::sequence_element_type(cx.tcx(), t);
|
let unit_ty = ty::sequence_element_type(cx.tcx(), t);
|
||||||
cx = tvec::iter_vec_raw(cx, data_ptr, unit_ty, info.unwrap(), f);
|
cx = tvec::iter_vec_raw(cx, data_ptr, unit_ty, info.unwrap(), f);
|
||||||
}
|
}
|
||||||
|
@ -246,7 +246,7 @@ pub fn type_is_immediate<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, ty: Ty<'tcx>) -
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
match ty.sty {
|
match ty.sty {
|
||||||
ty::TyStruct(..) | ty::TyEnum(..) | ty::TyTuple(..) | ty::TyArray(_, Some(_)) |
|
ty::TyStruct(..) | ty::TyEnum(..) | ty::TyTuple(..) | ty::TyArray(_, _) |
|
||||||
ty::TyClosure(..) => {
|
ty::TyClosure(..) => {
|
||||||
let llty = sizing_type_of(ccx, ty);
|
let llty = sizing_type_of(ccx, ty);
|
||||||
llsize_of_alloc(ccx, llty) <= llsize_of_alloc(ccx, ccx.int_type())
|
llsize_of_alloc(ccx, llty) <= llsize_of_alloc(ccx, ccx.int_type())
|
||||||
|
@ -609,13 +609,13 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||||||
"index is not an integer-constant expression")
|
"index is not an integer-constant expression")
|
||||||
};
|
};
|
||||||
let (arr, len) = match bt.sty {
|
let (arr, len) = match bt.sty {
|
||||||
ty::TyArray(_, Some(u)) => (bv, C_uint(cx, u)),
|
ty::TyArray(_, u) => (bv, C_uint(cx, u)),
|
||||||
ty::TyArray(_, None) | ty::TyStr => {
|
ty::TySlice(_) | ty::TyStr => {
|
||||||
let e1 = const_get_elt(cx, bv, &[0]);
|
let e1 = const_get_elt(cx, bv, &[0]);
|
||||||
(const_deref_ptr(cx, e1), const_get_elt(cx, bv, &[1]))
|
(const_deref_ptr(cx, e1), const_get_elt(cx, bv, &[1]))
|
||||||
}
|
}
|
||||||
ty::TyRef(_, mt) => match mt.ty.sty {
|
ty::TyRef(_, mt) => match mt.ty.sty {
|
||||||
ty::TyArray(_, Some(u)) => {
|
ty::TyArray(_, u) => {
|
||||||
(const_deref_ptr(cx, bv), C_uint(cx, u))
|
(const_deref_ptr(cx, bv), C_uint(cx, u))
|
||||||
},
|
},
|
||||||
_ => cx.sess().span_bug(base.span,
|
_ => cx.sess().span_bug(base.span,
|
||||||
|
@ -226,15 +226,15 @@ impl<'tcx> TypeMap<'tcx> {
|
|||||||
let inner_type_id = self.get_unique_type_id_as_string(inner_type_id);
|
let inner_type_id = self.get_unique_type_id_as_string(inner_type_id);
|
||||||
unique_type_id.push_str(&inner_type_id[..]);
|
unique_type_id.push_str(&inner_type_id[..]);
|
||||||
},
|
},
|
||||||
ty::TyArray(inner_type, optional_length) => {
|
ty::TyArray(inner_type, len) => {
|
||||||
match optional_length {
|
unique_type_id.push_str(&format!("[{}]", len));
|
||||||
Some(len) => {
|
|
||||||
unique_type_id.push_str(&format!("[{}]", len));
|
let inner_type_id = self.get_unique_type_id_of_type(cx, inner_type);
|
||||||
}
|
let inner_type_id = self.get_unique_type_id_as_string(inner_type_id);
|
||||||
None => {
|
unique_type_id.push_str(&inner_type_id[..]);
|
||||||
unique_type_id.push_str("[]");
|
},
|
||||||
}
|
ty::TySlice(inner_type) => {
|
||||||
};
|
unique_type_id.push_str("[]");
|
||||||
|
|
||||||
let inner_type_id = self.get_unique_type_id_of_type(cx, inner_type);
|
let inner_type_id = self.get_unique_type_id_of_type(cx, inner_type);
|
||||||
let inner_type_id = self.get_unique_type_id_as_string(inner_type_id);
|
let inner_type_id = self.get_unique_type_id_as_string(inner_type_id);
|
||||||
@ -756,7 +756,10 @@ pub fn type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||||||
prepare_enum_metadata(cx, t, def_id, unique_type_id, usage_site_span).finalize(cx)
|
prepare_enum_metadata(cx, t, def_id, unique_type_id, usage_site_span).finalize(cx)
|
||||||
}
|
}
|
||||||
ty::TyArray(typ, len) => {
|
ty::TyArray(typ, len) => {
|
||||||
fixed_vec_metadata(cx, unique_type_id, typ, len.map(|x| x as u64), usage_site_span)
|
fixed_vec_metadata(cx, unique_type_id, typ, Some(len as u64), usage_site_span)
|
||||||
|
}
|
||||||
|
ty::TySlice(typ) => {
|
||||||
|
fixed_vec_metadata(cx, unique_type_id, typ, None, usage_site_span)
|
||||||
}
|
}
|
||||||
ty::TyStr => {
|
ty::TyStr => {
|
||||||
fixed_vec_metadata(cx, unique_type_id, cx.tcx().types.i8, None, usage_site_span)
|
fixed_vec_metadata(cx, unique_type_id, cx.tcx().types.i8, None, usage_site_span)
|
||||||
@ -768,7 +771,7 @@ pub fn type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||||||
}
|
}
|
||||||
ty::TyBox(ty) | ty::TyRawPtr(ty::mt{ty, ..}) | ty::TyRef(_, ty::mt{ty, ..}) => {
|
ty::TyBox(ty) | ty::TyRawPtr(ty::mt{ty, ..}) | ty::TyRef(_, ty::mt{ty, ..}) => {
|
||||||
match ty.sty {
|
match ty.sty {
|
||||||
ty::TyArray(typ, None) => {
|
ty::TySlice(typ) => {
|
||||||
vec_slice_metadata(cx, t, typ, unique_type_id, usage_site_span)
|
vec_slice_metadata(cx, t, typ, unique_type_id, usage_site_span)
|
||||||
}
|
}
|
||||||
ty::TyStr => {
|
ty::TyStr => {
|
||||||
|
@ -94,17 +94,15 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||||||
|
|
||||||
push_debuginfo_type_name(cx, inner_type, true, output);
|
push_debuginfo_type_name(cx, inner_type, true, output);
|
||||||
},
|
},
|
||||||
ty::TyArray(inner_type, optional_length) => {
|
ty::TyArray(inner_type, len) => {
|
||||||
|
output.push('[');
|
||||||
|
push_debuginfo_type_name(cx, inner_type, true, output);
|
||||||
|
output.push_str(&format!("; {}", len));
|
||||||
|
output.push(']');
|
||||||
|
},
|
||||||
|
ty::TySlice(inner_type) => {
|
||||||
output.push('[');
|
output.push('[');
|
||||||
push_debuginfo_type_name(cx, inner_type, true, output);
|
push_debuginfo_type_name(cx, inner_type, true, output);
|
||||||
|
|
||||||
match optional_length {
|
|
||||||
Some(len) => {
|
|
||||||
output.push_str(&format!("; {}", len));
|
|
||||||
}
|
|
||||||
None => { /* nothing to do */ }
|
|
||||||
};
|
|
||||||
|
|
||||||
output.push(']');
|
output.push(']');
|
||||||
},
|
},
|
||||||
ty::TyTrait(ref trait_data) => {
|
ty::TyTrait(ref trait_data) => {
|
||||||
|
@ -313,7 +313,7 @@ pub fn unsized_info<'ccx, 'tcx>(ccx: &CrateContext<'ccx, 'tcx>,
|
|||||||
-> ValueRef {
|
-> ValueRef {
|
||||||
let (source, target) = ty::struct_lockstep_tails(ccx.tcx(), source, target);
|
let (source, target) = ty::struct_lockstep_tails(ccx.tcx(), source, target);
|
||||||
match (&source.sty, &target.sty) {
|
match (&source.sty, &target.sty) {
|
||||||
(&ty::TyArray(_, Some(len)), &ty::TyArray(_, None)) => C_uint(ccx, len),
|
(&ty::TyArray(_, len), &ty::TySlice(_)) => C_uint(ccx, len),
|
||||||
(&ty::TyTrait(_), &ty::TyTrait(_)) => {
|
(&ty::TyTrait(_), &ty::TyTrait(_)) => {
|
||||||
// For now, upcasts are limited to changes in marker
|
// For now, upcasts are limited to changes in marker
|
||||||
// traits, and hence never actually require an actual
|
// traits, and hence never actually require an actual
|
||||||
|
@ -435,7 +435,7 @@ pub fn size_and_align_of_dst<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, t: Ty<'tcx>, in
|
|||||||
let align_ptr = GEPi(bcx, info, &[2]);
|
let align_ptr = GEPi(bcx, info, &[2]);
|
||||||
(Load(bcx, size_ptr), Load(bcx, align_ptr))
|
(Load(bcx, size_ptr), Load(bcx, align_ptr))
|
||||||
}
|
}
|
||||||
ty::TyArray(_, None) | ty::TyStr => {
|
ty::TySlice(_) | ty::TyStr => {
|
||||||
let unit_ty = ty::sequence_element_type(bcx.tcx(), t);
|
let unit_ty = ty::sequence_element_type(bcx.tcx(), t);
|
||||||
// The info in this case is the length of the str, so the size is that
|
// The info in this case is the length of the str, so the size is that
|
||||||
// times the unit size.
|
// times the unit size.
|
||||||
|
@ -310,8 +310,8 @@ pub fn get_base_and_len<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||||||
let ccx = bcx.ccx();
|
let ccx = bcx.ccx();
|
||||||
|
|
||||||
match vec_ty.sty {
|
match vec_ty.sty {
|
||||||
ty::TyArray(_, Some(n)) => get_fixed_base_and_len(bcx, llval, n),
|
ty::TyArray(_, n) => get_fixed_base_and_len(bcx, llval, n),
|
||||||
ty::TyArray(_, None) | ty::TyStr => {
|
ty::TySlice(_) | ty::TyStr => {
|
||||||
let base = Load(bcx, expr::get_dataptr(bcx, llval));
|
let base = Load(bcx, expr::get_dataptr(bcx, llval));
|
||||||
let len = Load(bcx, expr::get_len(bcx, llval));
|
let len = Load(bcx, expr::get_len(bcx, llval));
|
||||||
(base, len)
|
(base, len)
|
||||||
|
@ -200,7 +200,7 @@ pub fn sizing_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> Typ
|
|||||||
|
|
||||||
ty::TyBareFn(..) => Type::i8p(cx),
|
ty::TyBareFn(..) => Type::i8p(cx),
|
||||||
|
|
||||||
ty::TyArray(ty, Some(size)) => {
|
ty::TyArray(ty, size) => {
|
||||||
let llty = sizing_type_of(cx, ty);
|
let llty = sizing_type_of(cx, ty);
|
||||||
let size = size as u64;
|
let size = size as u64;
|
||||||
ensure_array_fits_in_address_space(cx, llty, size, t);
|
ensure_array_fits_in_address_space(cx, llty, size, t);
|
||||||
@ -232,7 +232,7 @@ pub fn sizing_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> Typ
|
|||||||
cx.sess().bug(&format!("fictitious type {} in sizing_type_of()",
|
cx.sess().bug(&format!("fictitious type {} in sizing_type_of()",
|
||||||
ppaux::ty_to_string(cx.tcx(), t)))
|
ppaux::ty_to_string(cx.tcx(), t)))
|
||||||
}
|
}
|
||||||
ty::TyArray(_, None) | ty::TyTrait(..) | ty::TyStr => unreachable!()
|
ty::TySlice(_) | ty::TyTrait(..) | ty::TyStr => unreachable!()
|
||||||
};
|
};
|
||||||
|
|
||||||
cx.llsizingtypes().borrow_mut().insert(t, llsizingty);
|
cx.llsizingtypes().borrow_mut().insert(t, llsizingty);
|
||||||
@ -359,7 +359,7 @@ pub fn in_memory_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) ->
|
|||||||
let ptr_ty = in_memory_type_of(cx, ty).ptr_to();
|
let ptr_ty = in_memory_type_of(cx, ty).ptr_to();
|
||||||
let unsized_part = ty::struct_tail(cx.tcx(), ty);
|
let unsized_part = ty::struct_tail(cx.tcx(), ty);
|
||||||
let info_ty = match unsized_part.sty {
|
let info_ty = match unsized_part.sty {
|
||||||
ty::TyStr | ty::TyArray(..) => {
|
ty::TyStr | ty::TyArray(..) | ty::TySlice(_) => {
|
||||||
Type::uint_from_ty(cx, ast::TyUs)
|
Type::uint_from_ty(cx, ast::TyUs)
|
||||||
}
|
}
|
||||||
ty::TyTrait(_) => Type::vtable_ptr(cx),
|
ty::TyTrait(_) => Type::vtable_ptr(cx),
|
||||||
@ -374,7 +374,7 @@ pub fn in_memory_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) ->
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ty::TyArray(ty, Some(size)) => {
|
ty::TyArray(ty, size) => {
|
||||||
let size = size as u64;
|
let size = size as u64;
|
||||||
let llty = in_memory_type_of(cx, ty);
|
let llty = in_memory_type_of(cx, ty);
|
||||||
ensure_array_fits_in_address_space(cx, llty, size, t);
|
ensure_array_fits_in_address_space(cx, llty, size, t);
|
||||||
@ -385,7 +385,7 @@ pub fn in_memory_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) ->
|
|||||||
// traits have the type of u8. This is so that the data pointer inside
|
// traits have the type of u8. This is so that the data pointer inside
|
||||||
// fat pointers is of the right type (e.g. for array accesses), even
|
// fat pointers is of the right type (e.g. for array accesses), even
|
||||||
// when taking the address of an unsized field in a struct.
|
// when taking the address of an unsized field in a struct.
|
||||||
ty::TyArray(ty, None) => in_memory_type_of(cx, ty),
|
ty::TySlice(ty) => in_memory_type_of(cx, ty),
|
||||||
ty::TyStr | ty::TyTrait(..) => Type::i8(cx),
|
ty::TyStr | ty::TyTrait(..) => Type::i8(cx),
|
||||||
|
|
||||||
ty::TyBareFn(..) => {
|
ty::TyBareFn(..) => {
|
||||||
|
@ -59,7 +59,7 @@ pub fn check_pat<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>,
|
|||||||
if let ast::LitBinary(_) = lt.node {
|
if let ast::LitBinary(_) = lt.node {
|
||||||
let expected_ty = structurally_resolved_type(fcx, pat.span, expected);
|
let expected_ty = structurally_resolved_type(fcx, pat.span, expected);
|
||||||
if let ty::TyRef(_, mt) = expected_ty.sty {
|
if let ty::TyRef(_, mt) = expected_ty.sty {
|
||||||
if let ty::TyArray(_, None) = mt.ty.sty {
|
if let ty::TySlice(_) = mt.ty.sty {
|
||||||
pat_ty = ty::mk_slice(tcx, tcx.mk_region(ty::ReStatic),
|
pat_ty = ty::mk_slice(tcx, tcx.mk_region(ty::ReStatic),
|
||||||
ty::mt{ ty: tcx.types.u8, mutbl: ast::MutImmutable })
|
ty::mt{ ty: tcx.types.u8, mutbl: ast::MutImmutable })
|
||||||
}
|
}
|
||||||
@ -293,7 +293,7 @@ pub fn check_pat<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>,
|
|||||||
let expected_ty = structurally_resolved_type(fcx, pat.span, expected);
|
let expected_ty = structurally_resolved_type(fcx, pat.span, expected);
|
||||||
let inner_ty = fcx.infcx().next_ty_var();
|
let inner_ty = fcx.infcx().next_ty_var();
|
||||||
let pat_ty = match expected_ty.sty {
|
let pat_ty = match expected_ty.sty {
|
||||||
ty::TyArray(_, Some(size)) => ty::mk_vec(tcx, inner_ty, Some({
|
ty::TyArray(_, size) => ty::mk_vec(tcx, inner_ty, Some({
|
||||||
let min_len = before.len() + after.len();
|
let min_len = before.len() + after.len();
|
||||||
match *slice {
|
match *slice {
|
||||||
Some(_) => cmp::max(min_len, size),
|
Some(_) => cmp::max(min_len, size),
|
||||||
|
@ -74,7 +74,7 @@ fn unsize_kind<'a,'tcx>(fcx: &FnCtxt<'a, 'tcx>,
|
|||||||
t: Ty<'tcx>)
|
t: Ty<'tcx>)
|
||||||
-> Option<UnsizeKind<'tcx>> {
|
-> Option<UnsizeKind<'tcx>> {
|
||||||
match t.sty {
|
match t.sty {
|
||||||
ty::TyArray(_, None) | ty::TyStr => Some(UnsizeKind::Length),
|
ty::TySlice(_) | ty::TyStr => Some(UnsizeKind::Length),
|
||||||
ty::TyTrait(_) => Some(UnsizeKind::Vtable),
|
ty::TyTrait(_) => Some(UnsizeKind::Vtable),
|
||||||
ty::TyStruct(did, substs) => {
|
ty::TyStruct(did, substs) => {
|
||||||
match ty::struct_fields(fcx.tcx(), did, substs).pop() {
|
match ty::struct_fields(fcx.tcx(), did, substs).pop() {
|
||||||
@ -337,7 +337,7 @@ impl<'tcx> CastCheck<'tcx> {
|
|||||||
// array-ptr-cast.
|
// array-ptr-cast.
|
||||||
|
|
||||||
if m_expr.mutbl == ast::MutImmutable && m_cast.mutbl == ast::MutImmutable {
|
if m_expr.mutbl == ast::MutImmutable && m_cast.mutbl == ast::MutImmutable {
|
||||||
if let ty::TyArray(ety, Some(_)) = m_expr.ty.sty {
|
if let ty::TyArray(ety, _) = m_expr.ty.sty {
|
||||||
// Due to the limitations of LLVM global constants,
|
// Due to the limitations of LLVM global constants,
|
||||||
// region pointers end up pointing at copies of
|
// region pointers end up pointing at copies of
|
||||||
// vector elements instead of the original values.
|
// vector elements instead of the original values.
|
||||||
|
@ -202,7 +202,7 @@ fn create_steps<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
|
|||||||
});
|
});
|
||||||
|
|
||||||
match final_ty.sty {
|
match final_ty.sty {
|
||||||
ty::TyArray(elem_ty, Some(_)) => {
|
ty::TyArray(elem_ty, _) => {
|
||||||
let slice_ty = ty::mk_vec(fcx.tcx(), elem_ty, None);
|
let slice_ty = ty::mk_vec(fcx.tcx(), elem_ty, None);
|
||||||
steps.push(CandidateStep {
|
steps.push(CandidateStep {
|
||||||
self_ty: slice_ty,
|
self_ty: slice_ty,
|
||||||
@ -295,7 +295,7 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> {
|
|||||||
let lang_def_id = self.tcx().lang_items.str_impl();
|
let lang_def_id = self.tcx().lang_items.str_impl();
|
||||||
self.assemble_inherent_impl_for_primitive(lang_def_id);
|
self.assemble_inherent_impl_for_primitive(lang_def_id);
|
||||||
}
|
}
|
||||||
ty::TyArray(_, None) => {
|
ty::TySlice(_) => {
|
||||||
let lang_def_id = self.tcx().lang_items.slice_impl();
|
let lang_def_id = self.tcx().lang_items.slice_impl();
|
||||||
self.assemble_inherent_impl_for_primitive(lang_def_id);
|
self.assemble_inherent_impl_for_primitive(lang_def_id);
|
||||||
}
|
}
|
||||||
|
@ -2095,7 +2095,7 @@ fn lookup_indexing<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
|
|||||||
|
|
||||||
// After we have fully autoderef'd, if the resulting type is [T; n], then
|
// After we have fully autoderef'd, if the resulting type is [T; n], then
|
||||||
// do a final unsized coercion to yield [T].
|
// do a final unsized coercion to yield [T].
|
||||||
if let ty::TyArray(element_ty, Some(_)) = ty.sty {
|
if let ty::TyArray(element_ty, _) = ty.sty {
|
||||||
let adjusted_ty = ty::mk_vec(fcx.tcx(), element_ty, None);
|
let adjusted_ty = ty::mk_vec(fcx.tcx(), element_ty, None);
|
||||||
try_index_step(fcx, MethodCall::expr(expr.id), expr, base_expr,
|
try_index_step(fcx, MethodCall::expr(expr.id), expr, base_expr,
|
||||||
adjusted_ty, autoderefs, true, lvalue_pref, idx_ty)
|
adjusted_ty, autoderefs, true, lvalue_pref, idx_ty)
|
||||||
@ -3452,7 +3452,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
|
|||||||
ast::ExprVec(ref args) => {
|
ast::ExprVec(ref args) => {
|
||||||
let uty = expected.to_option(fcx).and_then(|uty| {
|
let uty = expected.to_option(fcx).and_then(|uty| {
|
||||||
match uty.sty {
|
match uty.sty {
|
||||||
ty::TyArray(ty, _) => Some(ty),
|
ty::TyArray(ty, _) | ty::TySlice(ty) => Some(ty),
|
||||||
_ => None
|
_ => None
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -3482,7 +3482,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
|
|||||||
let uty = match expected {
|
let uty = match expected {
|
||||||
ExpectHasType(uty) => {
|
ExpectHasType(uty) => {
|
||||||
match uty.sty {
|
match uty.sty {
|
||||||
ty::TyArray(ty, _) => Some(ty),
|
ty::TyArray(ty, _) | ty::TySlice(ty) => Some(ty),
|
||||||
_ => None
|
_ => None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3862,7 +3862,7 @@ impl<'tcx> Expectation<'tcx> {
|
|||||||
/// for examples of where this comes up,.
|
/// for examples of where this comes up,.
|
||||||
fn rvalue_hint(ty: Ty<'tcx>) -> Expectation<'tcx> {
|
fn rvalue_hint(ty: Ty<'tcx>) -> Expectation<'tcx> {
|
||||||
match ty.sty {
|
match ty.sty {
|
||||||
ty::TyArray(_, None) | ty::TyTrait(..) => {
|
ty::TySlice(_) | ty::TyTrait(..) => {
|
||||||
ExpectRvalueLikeUnsized(ty)
|
ExpectRvalueLikeUnsized(ty)
|
||||||
}
|
}
|
||||||
_ => ExpectHasType(ty)
|
_ => ExpectHasType(ty)
|
||||||
|
@ -997,7 +997,7 @@ fn constrain_index<'a, 'tcx>(rcx: &mut Rcx<'a, 'tcx>,
|
|||||||
let r_index_expr = ty::ReScope(CodeExtent::from_node_id(index_expr.id));
|
let r_index_expr = ty::ReScope(CodeExtent::from_node_id(index_expr.id));
|
||||||
if let ty::TyRef(r_ptr, mt) = indexed_ty.sty {
|
if let ty::TyRef(r_ptr, mt) = indexed_ty.sty {
|
||||||
match mt.ty.sty {
|
match mt.ty.sty {
|
||||||
ty::TyArray(_, None) | ty::TyStr => {
|
ty::TySlice(_) | ty::TyStr => {
|
||||||
rcx.fcx.mk_subr(infer::IndexSlice(index_expr.span),
|
rcx.fcx.mk_subr(infer::IndexSlice(index_expr.span),
|
||||||
r_index_expr, *r_ptr);
|
r_index_expr, *r_ptr);
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ use middle::ty::{MethodTraitItemId, TypeTraitItemId, ParameterEnvironment};
|
|||||||
use middle::ty::{Ty, TyBool, TyChar, TyEnum, TyError};
|
use middle::ty::{Ty, TyBool, TyChar, TyEnum, TyError};
|
||||||
use middle::ty::{TyParam, TypeScheme, TyRawPtr};
|
use middle::ty::{TyParam, TypeScheme, TyRawPtr};
|
||||||
use middle::ty::{TyRef, TyStruct, TyTrait, TyTuple};
|
use middle::ty::{TyRef, TyStruct, TyTrait, TyTuple};
|
||||||
use middle::ty::{TyStr, TyArray, TyFloat, TyInfer, TyInt};
|
use middle::ty::{TyStr, TyArray, TySlice, TyFloat, TyInfer, TyInt};
|
||||||
use middle::ty::{TyUint, TyClosure, TyBox, TyBareFn};
|
use middle::ty::{TyUint, TyClosure, TyBox, TyBareFn};
|
||||||
use middle::ty::TyProjection;
|
use middle::ty::TyProjection;
|
||||||
use middle::ty;
|
use middle::ty;
|
||||||
@ -70,7 +70,7 @@ fn get_base_type_def_id<'a, 'tcx>(inference_context: &InferCtxt<'a, 'tcx>,
|
|||||||
}
|
}
|
||||||
|
|
||||||
TyBool | TyChar | TyInt(..) | TyUint(..) | TyFloat(..) |
|
TyBool | TyChar | TyInt(..) | TyUint(..) | TyFloat(..) |
|
||||||
TyStr(..) | TyArray(..) | TyBareFn(..) | TyTuple(..) |
|
TyStr(..) | TyArray(..) | TySlice(..) | TyBareFn(..) | TyTuple(..) |
|
||||||
TyParam(..) | TyError |
|
TyParam(..) | TyError |
|
||||||
TyRawPtr(_) | TyRef(_, _) | TyProjection(..) => {
|
TyRawPtr(_) | TyRef(_, _) | TyProjection(..) => {
|
||||||
None
|
None
|
||||||
|
@ -93,7 +93,7 @@ impl<'cx, 'tcx> OrphanChecker<'cx, 'tcx> {
|
|||||||
"str",
|
"str",
|
||||||
item.span);
|
item.span);
|
||||||
}
|
}
|
||||||
ty::TyArray(_, None) => {
|
ty::TySlice(_) => {
|
||||||
self.check_primitive_impl(def_id,
|
self.check_primitive_impl(def_id,
|
||||||
self.tcx.lang_items.slice_impl(),
|
self.tcx.lang_items.slice_impl(),
|
||||||
"slice",
|
"slice",
|
||||||
|
@ -889,7 +889,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
|
|||||||
self.add_constraints_from_mt(generics, mt, variance);
|
self.add_constraints_from_mt(generics, mt, variance);
|
||||||
}
|
}
|
||||||
|
|
||||||
ty::TyBox(typ) | ty::TyArray(typ, _) => {
|
ty::TyBox(typ) | ty::TyArray(typ, _) | ty::TySlice(typ) => {
|
||||||
self.add_constraints_from_ty(generics, typ, variance);
|
self.add_constraints_from_ty(generics, typ, variance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1652,9 +1652,9 @@ impl<'tcx> Clean<Type> for ty::Ty<'tcx> {
|
|||||||
});
|
});
|
||||||
lang_struct(cx, box_did, t, "Box", Unique)
|
lang_struct(cx, box_did, t, "Box", Unique)
|
||||||
}
|
}
|
||||||
ty::TyArray(ty, None) => Vector(box ty.clean(cx)),
|
ty::TySlice(ty) => Vector(box ty.clean(cx)),
|
||||||
ty::TyArray(ty, Some(i)) => FixedVector(box ty.clean(cx),
|
ty::TyArray(ty, i) => FixedVector(box ty.clean(cx),
|
||||||
format!("{}", i)),
|
format!("{}", i)),
|
||||||
ty::TyRawPtr(mt) => RawPointer(mt.mutbl.clean(cx), box mt.ty.clean(cx)),
|
ty::TyRawPtr(mt) => RawPointer(mt.mutbl.clean(cx), box mt.ty.clean(cx)),
|
||||||
ty::TyRef(r, mt) => BorrowedRef {
|
ty::TyRef(r, mt) => BorrowedRef {
|
||||||
lifetime: r.clean(cx),
|
lifetime: r.clean(cx),
|
||||||
|
Loading…
Reference in New Issue
Block a user