]> git.lizzy.rs Git - rust.git/commitdiff
Split TyArray into TyArray and TySlice.
authorEli Friedman <eli.friedman@gmail.com>
Fri, 12 Jun 2015 23:50:13 +0000 (16:50 -0700)
committerEli Friedman <eli.friedman@gmail.com>
Fri, 12 Jun 2015 23:50:13 +0000 (16:50 -0700)
Arrays and slices are closely related, but not that closely; making the
separation more explicit is generally more clear.

34 files changed:
src/librustc/metadata/tyencode.rs
src/librustc/middle/check_const.rs
src/librustc/middle/check_match.rs
src/librustc/middle/fast_reject.rs
src/librustc/middle/implicator.rs
src/librustc/middle/infer/freshen.rs
src/librustc/middle/mem_categorization.rs
src/librustc/middle/traits/coherence.rs
src/librustc/middle/traits/select.rs
src/librustc/middle/ty.rs
src/librustc/middle/ty_fold.rs
src/librustc/middle/ty_relate/mod.rs
src/librustc/middle/ty_walk.rs
src/librustc/util/ppaux.rs
src/librustc_trans/trans/_match.rs
src/librustc_trans/trans/adt.rs
src/librustc_trans/trans/base.rs
src/librustc_trans/trans/common.rs
src/librustc_trans/trans/consts.rs
src/librustc_trans/trans/debuginfo/metadata.rs
src/librustc_trans/trans/debuginfo/type_names.rs
src/librustc_trans/trans/expr.rs
src/librustc_trans/trans/glue.rs
src/librustc_trans/trans/tvec.rs
src/librustc_trans/trans/type_of.rs
src/librustc_typeck/check/_match.rs
src/librustc_typeck/check/cast.rs
src/librustc_typeck/check/method/probe.rs
src/librustc_typeck/check/mod.rs
src/librustc_typeck/check/regionck.rs
src/librustc_typeck/coherence/mod.rs
src/librustc_typeck/coherence/orphan.rs
src/librustc_typeck/variance.rs
src/librustdoc/clean/mod.rs

index 8f78e97c4bb40f7b62bd25629b4b673d97b3cca3..72e96121a3a683ab8c8fe54e8241c0ff852f2345 100644 (file)
@@ -113,11 +113,12 @@ pub fn enc_ty<'a, 'tcx>(w: &mut Encoder, cx: &ctxt<'a, 'tcx>, t: Ty<'tcx>) {
         ty::TyArray(t, sz) => {
             mywrite!(w, "V");
             enc_ty(w, cx, t);
-            mywrite!(w, "/");
-            match sz {
-                Some(n) => mywrite!(w, "{}|", n),
-                None => mywrite!(w, "|"),
-            }
+            mywrite!(w, "/{}|", sz);
+        }
+        ty::TySlice(t) => {
+            mywrite!(w, "V");
+            enc_ty(w, cx, t);
+            mywrite!(w, "/|");
         }
         ty::TyStr => {
             mywrite!(w, "v");
index 2d27e9d2ed62c1fa7794e1d658c8d668f4a70ac1..125de300db169924fb08eca07dc611be7cb5d16a 100644 (file)
@@ -423,7 +423,7 @@ fn visit_expr(&mut self, ex: &ast::Expr) {
                 self.visit_expr(&**element);
                 // The count is checked elsewhere (typeck).
                 let count = match node_ty.sty {
-                    ty::TyArray(_, Some(n)) => n,
+                    ty::TyArray(_, n) => n,
                     _ => unreachable!()
                 };
                 // [element; 0] is always zero-sized.
@@ -851,10 +851,14 @@ fn borrow(&mut self,
                     }
                     let mutbl = bk.to_mutbl_lossy();
                     if mutbl == ast::MutMutable && self.mode == Mode::StaticMut {
-                        // Mutable slices are the only `&mut` allowed in globals,
-                        // but only in `static mut`, nowhere else.
+                        // Mutable slices are the only `&mut` allowed in
+                        // 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 {
-                            ty::TyArray(_, _) => break,
+                            ty::TyArray(_, _) | ty::TySlice(_) => break,
                             _ => {}
                         }
                     }
index f3ba9148ba61cf68db83d61076d40491872981fc..ea95536b811e60bf7e3754f44d0f78f0f05db2ab 100644 (file)
@@ -537,14 +537,14 @@ fn construct_witness(cx: &MatchCheckCtxt, ctor: &Constructor,
 
         ty::TyRef(_, ty::mt { ty, mutbl }) => {
             match ty.sty {
-               ty::TyArray(_, Some(n)) => match ctor {
+               ty::TyArray(_, n) => match ctor {
                     &Single => {
                         assert_eq!(pats_len, n);
                         ast::PatVec(pats.collect(), None, vec!())
                     },
                     _ => unreachable!()
                 },
-                ty::TyArray(_, None) => match ctor {
+                ty::TySlice(_) => match ctor {
                     &Slice(n) => {
                         assert_eq!(pats_len, n);
                         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);
             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(),
 
         ty::TyRef(_, ty::mt { ty, .. }) => match ty.sty {
-            ty::TyArray(_, None) =>
+            ty::TySlice(_) =>
                 range_inclusive(0, max_slice_length).map(|length| Slice(length)).collect(),
             _ => 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))),
         ast::PatVec(ref before, ref slice, ref after) =>
             match left_ty.sty {
-                ty::TyArray(_, Some(_)) => vec!(Single),
+                ty::TyArray(_, _) => vec!(Single),
                 _                      => if slice.is_some() {
                     range_inclusive(before.len() + after.len(), max_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::TyBox(_) => 1,
         ty::TyRef(_, ty::mt { ty, .. }) => match ty.sty {
-            ty::TyArray(_, None) => match *ctor {
+            ty::TySlice(_) => match *ctor {
                 Slice(length) => length,
                 ConstantValue(_) => 0,
                 _ => 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::TyArray(_, Some(n)) => n,
+        ty::TyArray(_, n) => n,
         _ => 0
     }
 }
index ee792989ccf1be477297e10320a57da04ee36828..168494043e5c452ec46dfc296a6c6c7555a89f6d 100644 (file)
@@ -55,7 +55,7 @@ pub fn simplify_type(tcx: &ty::ctxt,
         ty::TyFloat(float_type) => Some(FloatSimplifiedType(float_type)),
         ty::TyEnum(def_id, _) => Some(EnumSimplifiedType(def_id)),
         ty::TyStr => Some(StrSimplifiedType),
-        ty::TyArray(..) => Some(VecSimplifiedType),
+        ty::TyArray(..) | ty::TySlice(_) => Some(VecSimplifiedType),
         ty::TyRawPtr(_) => Some(PtrSimplifiedType),
         ty::TyTrait(ref trait_info) => {
             Some(TraitSimplifiedType(trait_info.principal_def_id()))
index 367d5efb54b3f4e8f8ae9b218df4391c58901b9e..fc9636ae3665f6df12fa2a3efccf0fbdf6a97a87 100644 (file)
@@ -117,6 +117,7 @@ fn accumulate_from_ty(&mut self, ty: Ty<'tcx>) {
             }
 
             ty::TyArray(t, _) |
+            ty::TySlice(t) |
             ty::TyRawPtr(ty::mt { ty: t, .. }) |
             ty::TyBox(t) => {
                 self.accumulate_from_ty(t)
index 6eb4fcce8873a676f5e8092446bf242447c95367..1aa54863c203af515971f76ee82b2a8366c4fcec 100644 (file)
@@ -159,6 +159,7 @@ fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> {
             ty::TyStr |
             ty::TyError |
             ty::TyArray(..) |
+            ty::TySlice(..) |
             ty::TyRawPtr(..) |
             ty::TyRef(..) |
             ty::TyBareFn(..) |
index d099b71c3f2aebda0a4f8815c39946c5cfdc17fa..6d8e412c8a5dd9c1f303b7016e9f4e869f2f5150 100644 (file)
@@ -230,7 +230,7 @@ fn deref_kind(t: Ty, context: DerefKindContext) -> McResult<deref_kind> {
             Ok(deref_interior(InteriorField(PositionalField(0))))
         }
 
-        ty::TyArray(_, _) | ty::TyStr => {
+        ty::TyArray(_, _) | ty::TySlice(_) | ty::TyStr => {
             // no deref of indexed content without supplying InteriorOffsetKind
             if let Some(context) = context {
                 Ok(deref_interior(InteriorElement(context, element_kind(t))))
@@ -843,7 +843,7 @@ pub fn cat_rvalue_node(&self,
         // Only promote `[T; 0]` before an RFC for rvalue promotions
         // is accepted.
         let qualif = match expr_ty.sty {
-            ty::TyArray(_, Some(0)) => qualif,
+            ty::TyArray(_, 0) => qualif,
             _ => check_const::ConstQualif::NOT_CONST
         };
 
@@ -1130,7 +1130,7 @@ fn vec_slice_info(tcx: &ty::ctxt,
                           -> (ast::Mutability, ty::Region) {
             match slice_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),
                 },
 
@@ -1669,10 +1669,10 @@ fn element_kind(t: Ty) -> ElementKind {
     match t.sty {
         ty::TyRef(_, ty::mt{ty, ..}) |
         ty::TyBox(ty) => match ty.sty {
-            ty::TyArray(_, None) => VecElement,
+            ty::TySlice(_) => VecElement,
             _ => OtherElement
         },
-        ty::TyArray(..) => VecElement,
+        ty::TyArray(..) | ty::TySlice(_) => VecElement,
         _ => OtherElement
     }
 }
index ae2454013e8fbf78522a7f210d71cd94b373a0b6..dcf37e7d56a1b70421421cfdac7ac54b461a3506 100644 (file)
@@ -306,6 +306,7 @@ fn ty_is_local_constructor<'tcx>(tcx: &ty::ctxt<'tcx>,
         ty::TyStr(..) |
         ty::TyBareFn(..) |
         ty::TyArray(..) |
+        ty::TySlice(..) |
         ty::TyRawPtr(..) |
         ty::TyRef(..) |
         ty::TyTuple(..) |
index ba5f0686f4822d2136be20a8e0af75d0180c9c32..5d8cdd44eaa538af8da846233f0805b5cffb8c09 100644 (file)
@@ -1429,7 +1429,7 @@ fn assemble_candidates_for_unsizing(&mut self,
             }
 
             // [T; n] -> [T].
-            (&ty::TyArray(_, Some(_)), &ty::TyArray(_, None)) => true,
+            (&ty::TyArray(_, _), &ty::TySlice(_)) => true,
 
             // Struct<T> -> Struct<U>.
             (&ty::TyStruct(def_id_a, _), &ty::TyStruct(def_id_b, _)) => {
@@ -1662,35 +1662,18 @@ fn builtin_bound(&mut self,
                 }
             }
 
-            ty::TyArray(element_ty, ref len) => {
-                // [T; n] and [T]
+            ty::TyArray(element_ty, _) => {
+                // [T; n]
                 match bound {
-                    ty::BoundCopy => {
-                        match *len {
-                            // [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::BoundCopy => ok_if(vec![element_ty]),
+                    ty::BoundSized => ok_if(Vec::new()),
                     ty::BoundSync | ty::BoundSend => {
                         self.tcx().sess.bug("Send/Sync shouldn't occur in builtin_bounds()");
                     }
                 }
             }
 
-            ty::TyStr => {
-                // Equivalent to [u8]
+            ty::TyStr | ty::TySlice(_) => {
                 match bound {
                     ty::BoundSync | ty::BoundSend => {
                         self.tcx().sess.bug("Send/Sync shouldn't occur in builtin_bounds()");
@@ -1855,7 +1838,7 @@ fn constituent_types_for_ty(&self, t: Ty<'tcx>) -> Option<Vec<Ty<'tcx>>> {
                 Some(vec![element_ty])
             },
 
-            ty::TyArray(element_ty, _) => {
+            ty::TyArray(element_ty, _) | ty::TySlice(element_ty) => {
                 Some(vec![element_ty])
             }
 
@@ -2510,7 +2493,7 @@ fn confirm_builtin_unsize_candidate(&mut self,
             }
 
             // [T; n] -> [T].
-            (&ty::TyArray(a, Some(_)), &ty::TyArray(b, None)) => {
+            (&ty::TyArray(a, _), &ty::TySlice(b)) => {
                 let origin = infer::Misc(obligation.cause.span);
                 if self.infcx.sub_types(false, origin, a, b).is_err() {
                     return Err(Unimplemented);
index 42bc399e822b943281ba9a96eff8a0f8584f4dfe..c24f1d3e7bedbd6ff536c6924280f7d5b662ac92 100644 (file)
@@ -906,7 +906,7 @@ impl<'tcx> ctxt<'tcx> {
     pub fn print_debug_stats(&self) {
         sty_debug_print!(
             self,
-            TyEnum, TyBox, TyArray, TyRawPtr, TyRef, TyBareFn, TyTrait,
+            TyEnum, TyBox, TyArray, TySlice, TyRawPtr, TyRef, TyBareFn, TyTrait,
             TyStruct, TyClosure, TyTuple, TyParam, TyInfer, TyProjection);
 
         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`.
     TyStr,
 
-    /// An array with the given length, or the pointee
-    /// of an array slice.  Written as `[T; n]`, or `[T]`.
-    /// FIXME: It probably makes sense to separate these.
-    TyArray(Ty<'tcx>, Option<usize>),
+    /// An array with the given length. Written as `[T; n]`.
+    TyArray(Ty<'tcx>, usize),
+
+    /// The pointee of an array slice.  Written as `[T]`.
+    TySlice(Ty<'tcx>),
 
     /// A raw pointer. Written as `*mut T` or `*const T`
     TyRawPtr(mt<'tcx>),
@@ -3047,7 +3048,7 @@ fn add_sty(&mut self, st: &TypeVariants) {
                 self.add_bounds(bounds);
             }
 
-            &TyBox(tt) | &TyArray(tt, _) => {
+            &TyBox(tt) | &TyArray(tt, _) | &TySlice(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> {
-    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> {
@@ -3480,29 +3484,17 @@ pub fn type_is_self(ty: Ty) -> bool {
 fn type_is_slice(ty: Ty) -> bool {
     match ty.sty {
         TyRawPtr(mt) | TyRef(_, mt) => match mt.ty.sty {
-            TyArray(_, None) | TyStr => true,
+            TySlice(_) | TyStr => true,
             _ => 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 {
     match ty.sty {
       TyStruct(..) | TyTuple(_) | TyEnum(..) |
-      TyArray(_, Some(_)) | TyClosure(..) => true,
+      TyArray(..) | TyClosure(..) => true,
       _ => 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> {
     match ty.sty {
-        TyArray(ty, _) => ty,
+        TyArray(ty, _) | TySlice(ty) => ty,
         TyStr => mk_mach_uint(cx, ast::TyU8),
         _ => cx.sess.bug(&format!("sequence_element_type called on non-sequence value: {}",
                                  ty_to_string(cx, ty))),
@@ -3816,17 +3808,18 @@ fn tc_ty<'tcx>(cx: &ctxt<'tcx>,
             TyRef(r, ref mt) => {
                 TC::ReachesFfiUnsafe | match mt.ty.sty {
                     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)),
                     _ => tc_ty(cx, mt.ty, cache).reference(borrowed_contents(*r, mt.mutbl)),
                 }
             }
 
-            TyArray(ty, Some(_)) => {
+            TyArray(ty, _) => {
                 tc_ty(cx, ty, cache)
             }
 
-            TyArray(ty, None) => {
+            TySlice(ty) => {
                 tc_ty(cx, ty, cache) | 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, ..
         }) => Some(true),
 
-        TyArray(..) | TyTrait(..) | TyTuple(..) |
+        TyArray(..) | TySlice(_) | TyTrait(..) | TyTuple(..) |
         TyClosure(..) | TyEnum(..) | TyStruct(..) |
         TyProjection(..) | TyParam(..) | TyInfer(..) | TyError => None
     }.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 {
         TyBool | TyChar | TyInt(..) | TyUint(..) | TyFloat(..) |
         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(..) |
         TyInfer(..) | TyError => None
@@ -4116,8 +4109,8 @@ fn subtypes_require<'tcx>(cx: &ctxt<'tcx>, seen: &mut Vec<DefId>,
             // fixed length vectors need special treatment compared to
             // normal vectors, since they don't necessarily have the
             // possibility to have length zero.
-            TyArray(_, Some(0)) => false, // don't need no contents
-            TyArray(ty, Some(_)) => type_requires(cx, seen, r_ty, ty),
+            TyArray(_, 0) => false, // don't need no contents
+            TyArray(ty, _) => type_requires(cx, seen, r_ty, ty),
 
             TyBool |
             TyChar |
@@ -4128,7 +4121,7 @@ fn subtypes_require<'tcx>(cx: &ctxt<'tcx>, seen: &mut Vec<DefId>,
             TyBareFn(..) |
             TyParam(_) |
             TyProjection(_) |
-            TyArray(_, None) => {
+            TySlice(_) => {
                 false
             }
             TyBox(typ) => {
@@ -4238,7 +4231,7 @@ fn are_inner_types_recursive<'tcx>(cx: &ctxt<'tcx>, sp: Span,
             }
             // Fixed-length vectors.
             // FIXME(#11924) Behavior undecided for zero-length vectors.
-            TyArray(ty, Some(_)) => {
+            TyArray(ty, _) => {
                 is_type_structurally_recursive(cx, sp, seen, ty)
             }
             TyStruct(did, substs) => {
@@ -4494,7 +4487,7 @@ pub fn type_content<'tcx>(ty: Ty<'tcx>) -> Ty<'tcx> {
 // Returns the type of ty[i]
 pub fn index<'tcx>(ty: Ty<'tcx>) -> Option<Ty<'tcx>> {
     match ty.sty {
-        TyArray(ty, _) => Some(ty),
+        TyArray(ty, _) | TySlice(ty) => Some(ty),
         _ => None
     }
 }
@@ -4504,7 +4497,7 @@ pub fn index<'tcx>(ty: Ty<'tcx>) -> Option<Ty<'tcx>> {
 // which can't actually be indexed.
 pub fn array_element_ty<'tcx>(tcx: &ctxt<'tcx>, ty: Ty<'tcx>) -> Option<Ty<'tcx>> {
     match ty.sty {
-        TyArray(ty, _) => Some(ty),
+        TyArray(ty, _) | TySlice(ty) => Some(ty),
         TyStr => Some(tcx.types.u8),
         _ => 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)),
         TyBox(_) => "box".to_string(),
-        TyArray(_, Some(n)) => format!("array of {} elements", n),
-        TyArray(_, None) => "slice".to_string(),
+        TyArray(_, n) => format!("array of {} elements", n),
+        TySlice(_) => "slice".to_string(),
         TyRawPtr(_) => "*-ptr".to_string(),
         TyRef(_, _) => "&-ptr".to_string(),
         TyBareFn(Some(_), _) => format!("fn item"),
@@ -6626,11 +6619,11 @@ macro_rules! hash { ($e:expr) => { $e.hash(state) }  }
                 TyBox(_) => {
                     byte!(9);
                 }
-                TyArray(_, Some(n)) => {
+                TyArray(_, n) => {
                     byte!(10);
                     n.hash(state);
                 }
-                TyArray(_, None) => {
+                TySlice(_) => {
                     byte!(11);
                 }
                 TyRawPtr(m) => {
@@ -6967,6 +6960,7 @@ pub fn accumulate_lifetimes_in_type(accumulator: &mut Vec<ty::Region>,
             TyBox(_) |
             TyStr |
             TyArray(_, _) |
+            TySlice(_) |
             TyRawPtr(_) |
             TyBareFn(..) |
             TyTuple(_) |
index 40d5dab15a4938e0efe8d46202b643ba9df90c02..38391438298ee8a69b95964573913187485e0614 100644 (file)
@@ -599,6 +599,9 @@ pub fn super_fold_ty<'tcx, T: TypeFolder<'tcx>>(this: &mut T,
         ty::TyArray(typ, sz) => {
             ty::TyArray(typ.fold_with(this), sz)
         }
+        ty::TySlice(typ) => {
+            ty::TySlice(typ.fold_with(this))
+        }
         ty::TyEnum(tid, ref substs) => {
             let substs = substs.fold_with(this);
             ty::TyEnum(tid, this.tcx().mk_substs(substs))
index c79fe7f5ad10a837068f581b36ffbff5576c0031..91169af4adbe309da6b83a96d72f079732eb8557 100644 (file)
@@ -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))
         }
 
-        (&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));
             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));
             Ok(ty::mk_vec(tcx, t, None))
index 50118ed6e9fa7a24875a81f4aeec0000f8e63b1e..b34eb2ddb1e913ebfae6ba52e55013321f3929d6 100644 (file)
@@ -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::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);
         }
         ty::TyRawPtr(ref mt) | ty::TyRef(_, ref mt) => {
index 5d68c9d9b28f3a7bf821d40b41c438865cb5cff2..7341420c553585ab7671602c41def9d2f91ac719 100644 (file)
@@ -20,7 +20,7 @@
 use middle::ty::{ReSkolemized, ReVar, BrEnv};
 use middle::ty::{mt, Ty, ParamTy};
 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::TyClosure;
 use middle::ty::{TyBox, TyTrait, TyInt, TyUint, TyInfer};
@@ -432,11 +432,10 @@ fn infer_ty_to_string(cx: &ctxt, ty: ty::InferTy) -> String {
             })
         }
         TyArray(t, sz) => {
-            let inner_str = ty_to_string(cx, t);
-            match sz {
-                Some(n) => format!("[{}; {}]", inner_str, n),
-                None => format!("[{}]", inner_str),
-            }
+            format!("[{}; {}]", ty_to_string(cx, t), sz)
+        }
+        TySlice(t) => {
+            format!("[{}]", ty_to_string(cx, t))
         }
     }
 }
index bcf5922fb3de7fdf3e9aee265a105a5525926245..d2a7b3198f8dd65b073c8e4f88f0c8402e20cc3d 100644 (file)
@@ -852,7 +852,7 @@ fn compare_str<'blk, 'tcx>(cx: Block<'blk, 'tcx>,
     match rhs_t.sty {
         ty::TyRef(_, mt) => match mt.ty.sty {
             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) => {
                     // NOTE: cast &[u8] and &[u8; N] to &str and abuse the str_eq lang item,
                     // 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)))
     } else {
         match left_ty.sty {
-            ty::TyArray(_, Some(n)) => {
+            ty::TyArray(_, n) => {
                 let args = extract_vec_elems(bcx, left_ty, n, 0, val);
                 Some(args.vals)
             }
index 977b2b69c4685eb9976649e592695e085309435d..d9e1a75d3dcdc6fdb581d25b84d0000f0a58c0f0 100644 (file)
@@ -472,7 +472,7 @@ fn find_discr_field_candidate<'tcx>(tcx: &ty::ctxt<'tcx>,
 
         // Is this a fixed-size array of something non-zero
         // 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) {
                 vpath.push(0);
                 Some(vpath)
index cdb036bc6a9ab86b84356b05c25ce7f0ac230b17..0ec2d1abb09bda1d35d270fe84da492700daf26f 100644 (file)
@@ -444,12 +444,12 @@ fn iter_variant<'blk, 'tcx, F>(cx: Block<'blk, 'tcx>,
               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 unit_ty = ty::sequence_element_type(cx.tcx(), t);
         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);
         cx = tvec::iter_vec_raw(cx, data_ptr, unit_ty, info.unwrap(), f);
       }
index 7fe879dad0a721f8dc78870defb13d8b56d6d5f2..0f8fd45b05ac16bb6e831a78e03623b7320eb123 100644 (file)
@@ -246,7 +246,7 @@ pub fn type_is_immediate<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, ty: Ty<'tcx>) -
         return false;
     }
     match ty.sty {
-        ty::TyStruct(..) | ty::TyEnum(..) | ty::TyTuple(..) | ty::TyArray(_, Some(_)) |
+        ty::TyStruct(..) | ty::TyEnum(..) | ty::TyTuple(..) | ty::TyArray(_, _) |
         ty::TyClosure(..) => {
             let llty = sizing_type_of(ccx, ty);
             llsize_of_alloc(ccx, llty) <= llsize_of_alloc(ccx, ccx.int_type())
index 50dbeafa7e1735b53608898061b88f70d38b13d1..f7d1fad19a1660f7b134374ab69b2b5c714b2c24 100644 (file)
@@ -609,13 +609,13 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
                                           "index is not an integer-constant expression")
               };
               let (arr, len) = match bt.sty {
-                  ty::TyArray(_, Some(u)) => (bv, C_uint(cx, u)),
-                  ty::TyArray(_, None) | ty::TyStr => {
+                  ty::TyArray(_, u) => (bv, C_uint(cx, u)),
+                  ty::TySlice(_) | ty::TyStr => {
                       let e1 = const_get_elt(cx, bv, &[0]);
                       (const_deref_ptr(cx, e1), const_get_elt(cx, bv, &[1]))
                   }
                   ty::TyRef(_, mt) => match mt.ty.sty {
-                      ty::TyArray(_, Some(u)) => {
+                      ty::TyArray(_, u) => {
                           (const_deref_ptr(cx, bv), C_uint(cx, u))
                       },
                       _ => cx.sess().span_bug(base.span,
index 551ccfb6650d05c06cecb81fea316ac67b16b854..42aa96ed21e9cf02dda349fdf9035d551d8ffe76 100644 (file)
@@ -226,15 +226,15 @@ fn get_unique_type_id_of_type<'a>(&mut self, cx: &CrateContext<'a, 'tcx>,
                 let inner_type_id = self.get_unique_type_id_as_string(inner_type_id);
                 unique_type_id.push_str(&inner_type_id[..]);
             },
-            ty::TyArray(inner_type, optional_length) => {
-                match optional_length {
-                    Some(len) => {
-                        unique_type_id.push_str(&format!("[{}]", len));
-                    }
-                    None => {
-                        unique_type_id.push_str("[]");
-                    }
-                };
+            ty::TyArray(inner_type, 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);
+                unique_type_id.push_str(&inner_type_id[..]);
+            },
+            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_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)
         }
         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 => {
             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, ..}) => {
             match ty.sty {
-                ty::TyArray(typ, None) => {
+                ty::TySlice(typ) => {
                     vec_slice_metadata(cx, t, typ, unique_type_id, usage_site_span)
                 }
                 ty::TyStr => {
index 153170913ed7e48ce4e893295fa3f5129b5b19ed..7d6c053cd1bf48b068661e7a495d645c54242a57 100644 (file)
@@ -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);
         },
-        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('[');
             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(']');
         },
         ty::TyTrait(ref trait_data) => {
index 9fda58db5d27eddc702cc65cc6502ff22ab87ada..07a8cbc38d5755908199b9adb8308c8ee7a44cb7 100644 (file)
@@ -313,7 +313,7 @@ pub fn unsized_info<'ccx, 'tcx>(ccx: &CrateContext<'ccx, 'tcx>,
                                 -> ValueRef {
     let (source, target) = ty::struct_lockstep_tails(ccx.tcx(), source, target);
     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(_)) => {
             // For now, upcasts are limited to changes in marker
             // traits, and hence never actually require an actual
index da1409a8f3db53749e16c04e2be383653a4a17b8..c7f5b86412cae7ade6fa87676a02c26f978b94b0 100644 (file)
@@ -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]);
             (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);
             // The info in this case is the length of the str, so the size is that
             // times the unit size.
index 18c123cec28c2170ff1826fbd860f74dec66f59c..3df6c904c7bc00cd47dd12e6ca6e55ed07ae587c 100644 (file)
@@ -310,8 +310,8 @@ pub fn get_base_and_len<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
     let ccx = bcx.ccx();
 
     match vec_ty.sty {
-        ty::TyArray(_, Some(n)) => get_fixed_base_and_len(bcx, llval, n),
-        ty::TyArray(_, None) | ty::TyStr => {
+        ty::TyArray(_, n) => get_fixed_base_and_len(bcx, llval, n),
+        ty::TySlice(_) | ty::TyStr => {
             let base = Load(bcx, expr::get_dataptr(bcx, llval));
             let len = Load(bcx, expr::get_len(bcx, llval));
             (base, len)
index 0356bade22da65a43d9a035c0ce4116eed9517c1..763d0581d6fb4c4e962eda86cf807466dad24415 100644 (file)
@@ -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::TyArray(ty, Some(size)) => {
+        ty::TyArray(ty, size) => {
             let llty = sizing_type_of(cx, ty);
             let size = size as u64;
             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()",
                                   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);
@@ -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 unsized_part = ty::struct_tail(cx.tcx(), ty);
                   let info_ty = match unsized_part.sty {
-                      ty::TyStr | ty::TyArray(..) => {
+                      ty::TyStr | ty::TyArray(..) | ty::TySlice(_) => {
                           Type::uint_from_ty(cx, ast::TyUs)
                       }
                       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 llty = in_memory_type_of(cx, ty);
           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
       // fat pointers is of the right type (e.g. for array accesses), even
       // 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::TyBareFn(..) => {
index 3df93ee7dbff1618f88bcd92fdbd23b04994c768..2f1447e0714685d68811c5da78a71e2959317236 100644 (file)
@@ -59,7 +59,7 @@ pub fn check_pat<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>,
                 if let ast::LitBinary(_) = lt.node {
                     let expected_ty = structurally_resolved_type(fcx, pat.span, expected);
                     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),
                                 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 inner_ty = fcx.infcx().next_ty_var();
             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();
                     match *slice {
                         Some(_) => cmp::max(min_len, size),
index 04a357b6c115decb404719338b6a64d4fd16b8af..6e306047f75c93632c5d23b02a39a57d22c059a6 100644 (file)
@@ -74,7 +74,7 @@ fn unsize_kind<'a,'tcx>(fcx: &FnCtxt<'a, 'tcx>,
                         t: Ty<'tcx>)
                         -> Option<UnsizeKind<'tcx>> {
     match t.sty {
-        ty::TyArray(_, None) | ty::TyStr => Some(UnsizeKind::Length),
+        ty::TySlice(_) | ty::TyStr => Some(UnsizeKind::Length),
         ty::TyTrait(_) => Some(UnsizeKind::Vtable),
         ty::TyStruct(did, substs) => {
             match ty::struct_fields(fcx.tcx(), did, substs).pop() {
@@ -337,7 +337,7 @@ fn check_ref_cast<'a>(&self,
         // array-ptr-cast.
 
         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,
                 // region pointers end up pointing at copies of
                 // vector elements instead of the original values.
index e7fd6f7834ad14a44273232a9d320b4d35ab40e7..79449b2f10d43b856f4bf534875bd7a49ba71f93 100644 (file)
@@ -202,7 +202,7 @@ fn create_steps<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
     });
 
     match final_ty.sty {
-        ty::TyArray(elem_ty, Some(_)) => {
+        ty::TyArray(elem_ty, _) => {
             let slice_ty = ty::mk_vec(fcx.tcx(), elem_ty, None);
             steps.push(CandidateStep {
                 self_ty: slice_ty,
@@ -295,7 +295,7 @@ fn assemble_probe(&mut self, self_ty: Ty<'tcx>) {
                 let lang_def_id = self.tcx().lang_items.str_impl();
                 self.assemble_inherent_impl_for_primitive(lang_def_id);
             }
-            ty::TyArray(_, None) => {
+            ty::TySlice(_) => {
                 let lang_def_id = self.tcx().lang_items.slice_impl();
                 self.assemble_inherent_impl_for_primitive(lang_def_id);
             }
index 9cab4a477321745abaf6f6d5cec37f0e9dad3077..69f1b5091df4621f2af3eba574fe2c24dde2e192 100644 (file)
@@ -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
     // 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);
         try_index_step(fcx, MethodCall::expr(expr.id), expr, base_expr,
                        adjusted_ty, autoderefs, true, lvalue_pref, idx_ty)
@@ -3452,7 +3452,7 @@ fn check_struct_fields_on_error<'a,'tcx>(fcx: &FnCtxt<'a,'tcx>,
       ast::ExprVec(ref args) => {
         let uty = expected.to_option(fcx).and_then(|uty| {
             match uty.sty {
-                ty::TyArray(ty, _) => Some(ty),
+                ty::TyArray(ty, _) | ty::TySlice(ty) => Some(ty),
                 _ => None
             }
         });
@@ -3482,7 +3482,7 @@ fn check_struct_fields_on_error<'a,'tcx>(fcx: &FnCtxt<'a,'tcx>,
         let uty = match expected {
             ExpectHasType(uty) => {
                 match uty.sty {
-                    ty::TyArray(ty, _) => Some(ty),
+                    ty::TyArray(ty, _) | ty::TySlice(ty) => Some(ty),
                     _ => None
                 }
             }
@@ -3862,7 +3862,7 @@ impl<'tcx> Expectation<'tcx> {
     /// for examples of where this comes up,.
     fn rvalue_hint(ty: Ty<'tcx>) -> Expectation<'tcx> {
         match ty.sty {
-            ty::TyArray(_, None) | ty::TyTrait(..) => {
+            ty::TySlice(_) | ty::TyTrait(..) => {
                 ExpectRvalueLikeUnsized(ty)
             }
             _ => ExpectHasType(ty)
index 2b2cb31836c02dc521ee2d180bc88336e1552fae..cb4d048ab374be61070a5ca019886a1e1b017271 100644 (file)
@@ -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));
     if let ty::TyRef(r_ptr, mt) = indexed_ty.sty {
         match mt.ty.sty {
-            ty::TyArray(_, None) | ty::TyStr => {
+            ty::TySlice(_) | ty::TyStr => {
                 rcx.fcx.mk_subr(infer::IndexSlice(index_expr.span),
                                 r_index_expr, *r_ptr);
             }
index 5a6cf7cccfd33ac8bea9fe5602f817f32d48f849..f6a40eec5829c2f6ed8fd497702678cf4434a591 100644 (file)
@@ -25,7 +25,7 @@
 use middle::ty::{Ty, TyBool, TyChar, TyEnum, TyError};
 use middle::ty::{TyParam, TypeScheme, TyRawPtr};
 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::TyProjection;
 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(..) |
-        TyStr(..) | TyArray(..) | TyBareFn(..) | TyTuple(..) |
+        TyStr(..) | TyArray(..) | TySlice(..) | TyBareFn(..) | TyTuple(..) |
         TyParam(..) | TyError |
         TyRawPtr(_) | TyRef(_, _) | TyProjection(..) => {
             None
index da01d4669f8e7244e5ba26ff74dfad2681c2bf5c..d815893524ff3b1f79c69f2dbbe28f7edbd11a6f 100644 (file)
@@ -93,7 +93,7 @@ fn check_item(&self, item: &ast::Item) {
                                                   "str",
                                                   item.span);
                     }
-                    ty::TyArray(_, None) => {
+                    ty::TySlice(_) => {
                         self.check_primitive_impl(def_id,
                                                   self.tcx.lang_items.slice_impl(),
                                                   "slice",
index c17e3038a8b2d813b5437aee967de91c471c571d..37088701adcd6ff7ca06fea6727fda6c59e9f1d8 100644 (file)
@@ -889,7 +889,7 @@ fn add_constraints_from_ty(&mut self,
                 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);
             }
 
index 920902e19c8232ed31f1caa28ded118be18e6c82..77409f2746a5750b238734a765e4759ca50856e6 100644 (file)
@@ -1652,9 +1652,9 @@ fn clean(&self, cx: &DocContext) -> Type {
                 });
                 lang_struct(cx, box_did, t, "Box", Unique)
             }
-            ty::TyArray(ty, None) => Vector(box ty.clean(cx)),
-            ty::TyArray(ty, Some(i)) => FixedVector(box ty.clean(cx),
-                                                   format!("{}", i)),
+            ty::TySlice(ty) => Vector(box ty.clean(cx)),
+            ty::TyArray(ty, i) => FixedVector(box ty.clean(cx),
+                                              format!("{}", i)),
             ty::TyRawPtr(mt) => RawPointer(mt.mutbl.clean(cx), box mt.ty.clean(cx)),
             ty::TyRef(r, mt) => BorrowedRef {
                 lifetime: r.clean(cx),