]> git.lizzy.rs Git - rust.git/commitdiff
Remove internal support for fixed length strings
authorNick Cameron <ncameron@mozilla.com>
Tue, 29 Apr 2014 01:10:23 +0000 (13:10 +1200)
committerNick Cameron <ncameron@mozilla.com>
Tue, 29 Apr 2014 01:10:23 +0000 (13:10 +1200)
26 files changed:
src/librustc/metadata/tydecode.rs
src/librustc/metadata/tyencode.rs
src/librustc/middle/check_match.rs
src/librustc/middle/effect.rs
src/librustc/middle/mem_categorization.rs
src/librustc/middle/trans/_match.rs
src/librustc/middle/trans/adt.rs
src/librustc/middle/trans/base.rs
src/librustc/middle/trans/callee.rs
src/librustc/middle/trans/consts.rs
src/librustc/middle/trans/debuginfo.rs
src/librustc/middle/trans/expr.rs
src/librustc/middle/trans/glue.rs
src/librustc/middle/trans/reflect.rs
src/librustc/middle/trans/tvec.rs
src/librustc/middle/trans/type_of.rs
src/librustc/middle/ty.rs
src/librustc/middle/ty_fold.rs
src/librustc/middle/typeck/astconv.rs
src/librustc/middle/typeck/check/method.rs
src/librustc/middle/typeck/check/mod.rs
src/librustc/middle/typeck/check/regionck.rs
src/librustc/middle/typeck/infer/coercion.rs
src/librustc/middle/typeck/infer/combine.rs
src/librustc/middle/typeck/variance.rs
src/librustc/util/ppaux.rs

index 30cce6d15f718681c1c44e8c57c77eff2a645d11..d0501c01aae50bf0498d8fc8ecd46f3ff63cdfb2 100644 (file)
@@ -344,8 +344,7 @@ fn parse_ty(st: &mut PState, conv: conv_did) -> ty::t {
         return ty::mk_vec(st.tcx, mt, sz);
       }
       'v' => {
-        let sz = parse_size(st);
-        return ty::mk_str(st.tcx, sz);
+        return ty::mk_str(st.tcx);
       }
       'T' => {
         assert_eq!(next(st), '[');
index 333c45bb356b8a68a32204fb4acd1e2003d044b0..3a196c5ffab5f30a345bd2461eee0742a571525f 100644 (file)
@@ -260,13 +260,8 @@ fn enc_sty(w: &mut MemWriter, cx: &ctxt, st: &ty::sty) {
                 None => mywrite!(w, "|"),
             }
         }
-        ty::ty_str(sz) => {
+        ty::ty_str => {
             mywrite!(w, "v");
-            mywrite!(w, "/");
-            match sz {
-                Some(n) => mywrite!(w, "{}|", n),
-                None => mywrite!(w, "|"),
-            }
         }
         ty::ty_closure(ref f) => {
             mywrite!(w, "f");
index cf66a10f46bb02f2a046f052cc6a1ac16bada330..842c10a0ca08bcfe430c92312bfcbc6a9afbed67 100644 (file)
@@ -405,7 +405,7 @@ fn missing_ctor(cx: &MatchCheckCtxt,
       ty::ty_struct(..) => check_matrix_for_wild(cx, m),
       ty::ty_uniq(ty) | ty::ty_rptr(_, ty::mt{ty: ty, ..}) => match ty::get(ty).sty {
           ty::ty_vec(_, None) => ctor_for_slice(m),
-          ty::ty_str(None) => Some(single),
+          ty::ty_str => Some(single),
           _ => check_matrix_for_wild(cx, m),
       },
       ty::ty_enum(eid, _) => {
index c77477116a5f1604f179b4cd134d98567d0eb28a..21fd963c21fc56a87a35ffa2aa0cb0bb3981b2bb 100644 (file)
@@ -69,13 +69,13 @@ fn check_str_index(&mut self, e: @ast::Expr) {
                 ppaux::ty_to_str(self.tcx, base_type));
         match ty::get(base_type).sty {
             ty::ty_uniq(ty) | ty::ty_rptr(_, ty::mt{ty, ..}) => match ty::get(ty).sty {
-                ty::ty_str(None) => {
+                ty::ty_str => {
                     self.tcx.sess.span_err(e.span,
                         "modification of string types is not allowed");
                 }
                 _ => {}
             },
-            ty::ty_str(..) => {
+            ty::ty_str => {
                 self.tcx.sess.span_err(e.span,
                     "modification of string types is not allowed");
             }
index 2d80e37db17429f908cac498d18a01a30c46723a..ea2b57b34d9b92f0c9781e48b95a6b55286eacf4 100644 (file)
@@ -204,8 +204,7 @@ pub fn opt_deref_kind(t: ty::t) -> Option<deref_kind> {
             Some(deref_interior(InteriorField(PositionalField(0))))
         }
 
-        ty::ty_vec(_, Some(_)) |
-        ty::ty_str(Some(_)) => {
+        ty::ty_vec(_, Some(_)) => {
             Some(deref_interior(InteriorElement(element_kind(t))))
         }
 
@@ -1304,11 +1303,10 @@ fn element_kind(t: ty::t) -> ElementKind {
         ty::ty_rptr(_, ty::mt{ty:ty, ..}) |
         ty::ty_uniq(ty) => match ty::get(ty).sty {
             ty::ty_vec(_, None) => VecElement,
-            ty::ty_str(None) => StrElement,
+            ty::ty_str => StrElement,
             _ => OtherElement
         },
         ty::ty_vec(..) => VecElement,
-        ty::ty_str(..) => StrElement,
         _ => OtherElement
     }
 }
index eea8e129066e76f7c00866096c9fbb860aa2e0c1..9d8f668a4e1f627fc5aa6796f9a8dc4d5ec0cb46 100644 (file)
@@ -1316,7 +1316,7 @@ fn compare_str<'a>(cx: &'a Block<'a>,
 
     match ty::get(rhs_t).sty {
         ty::ty_uniq(t) => match ty::get(t).sty {
-            ty::ty_str(None) => {
+            ty::ty_str => {
                 let scratch_lhs = alloca(cx, val_ty(lhs), "__lhs");
                 Store(cx, lhs, scratch_lhs);
                 let scratch_rhs = alloca(cx, val_ty(rhs), "__rhs");
@@ -1333,10 +1333,9 @@ fn compare_str<'a>(cx: &'a Block<'a>,
             _ => cx.sess().bug("only scalars and strings supported in compare_values"),
         },
         ty::ty_rptr(_, mt) => match ty::get(mt.ty).sty {
-            ty::ty_str(None) => compare_str(cx, lhs, rhs, rhs_t),
+            ty::ty_str => compare_str(cx, lhs, rhs, rhs_t),
             _ => cx.sess().bug("only scalars and strings supported in compare_values"),
         },
-        ty::ty_str(Some(_)) => compare_str(cx, lhs, rhs, rhs_t),
         _ => cx.sess().bug("only scalars and strings supported in compare_values"),
     }
 }
index 1cfaaacd11b3adb90ee917b2c71c01f2a3e2c1bf..03fc85126a4768318b46ec1b28b083ba298a8de0 100644 (file)
@@ -270,7 +270,7 @@ fn find_ptr(&self) -> Option<uint> {
         self.tys.iter().position(|&ty| {
             match ty::get(ty).sty {
                 ty::ty_rptr(_, mt) => match ty::get(mt.ty).sty {
-                    ty::ty_vec(_, None) | ty::ty_str(None)=> false,
+                    ty::ty_vec(_, None) | ty::ty_str => false,
                     _ => true,
                 },
                 ty::ty_uniq(..) | ty::ty_box(..) |
index 6084523f7f670046da25a0d1795e8590a5b5f486..0999da60ad3e4ee787f3ed94a5e992f73f04b068 100644 (file)
@@ -664,11 +664,6 @@ fn iter_variant<'r,
               }
           })
       }
-      ty::ty_str(Some(n)) => {
-        let unit_ty = ty::sequence_element_type(cx.tcx(), t);
-        let (base, len) = tvec::get_fixed_base_and_byte_len(cx, av, unit_ty, n);
-        cx = tvec::iter_vec_raw(cx, base, unit_ty, len, f);
-      }
       ty::ty_vec(_, Some(n)) => {
         let unit_ty = ty::sequence_element_type(cx.tcx(), t);
         let (base, len) = tvec::get_fixed_base_and_byte_len(cx, av, unit_ty, n);
index aee3300b3e6d861bd3671772aa25b33532de373c..c90ac8a29ef381c2f884e720363cc8e6ddc52886 100644 (file)
@@ -660,7 +660,7 @@ pub fn trans_call_inner<'a>(
             // `~` pointer return values never alias because ownership
             // is transferred
             ty::ty_uniq(ty) => match ty::get(ty).sty {
-                ty::ty_str(None) => {}
+                ty::ty_str => {}
                 _ => attrs.push((0, NoAliasAttribute)),
             },
             _ => {}
index 6a3d2419cc6096818b2872823346b397de3e20ae..eae9da84a1fe6727885965175662132655890edb 100644 (file)
@@ -141,7 +141,7 @@ fn const_deref(cx: &CrateContext, v: ValueRef, t: ty::t, explicit: bool)
             let dv = match ty::get(t).sty {
                 ty::ty_ptr(mt) | ty::ty_rptr(_, mt) => {
                     match ty::get(mt.ty).sty {
-                        ty::ty_vec(_, None) | ty::ty_str(None) => cx.sess().bug("unexpected slice"),
+                        ty::ty_vec(_, None) | ty::ty_str => cx.sess().bug("unexpected slice"),
                         _ => const_deref_ptr(cx, v),
                     }
                 }
@@ -434,7 +434,7 @@ fn const_expr_unadjusted(cx: &CrateContext, e: &ast::Expr,
               let (arr, len) = match ty::get(bt).sty {
                   ty::ty_vec(_, Some(u)) => (bv, C_uint(cx, u)),
                   ty::ty_rptr(_, mt) => match ty::get(mt.ty).sty {
-                      ty::ty_vec(_, None) | ty::ty_str(None) => {
+                      ty::ty_vec(_, None) | ty::ty_str => {
                           let e1 = const_get_elt(cx, bv, [0]);
                           (const_deref_ptr(cx, e1), const_get_elt(cx, bv, [1]))
                       },
@@ -448,16 +448,12 @@ fn const_expr_unadjusted(cx: &CrateContext, e: &ast::Expr,
               let len = llvm::LLVMConstIntGetZExtValue(len) as u64;
               let len = match ty::get(bt).sty {
                   ty::ty_uniq(ty) | ty::ty_rptr(_, ty::mt{ty, ..}) => match ty::get(ty).sty {
-                      ty::ty_str(None) => {
+                      ty::ty_str => {
                           assert!(len > 0);
                           len - 1
                       }
                       _ => len
                   },
-                  ty::ty_str(Some(_)) => {
-                      assert!(len > 0);
-                      len - 1
-                  },
                   _ => len
               };
               if iv >= len {
index 49c41d5cda97457d46b2e35bfb95ebdfa54078dc..a47e5a049405b7963251ca68b445a054681470da 100644 (file)
@@ -2183,10 +2183,6 @@ fn create_pointer_to_box_metadata(cx: &CrateContext,
         ty::ty_float(_) => {
             basic_type_metadata(cx, t)
         }
-        ty::ty_str(Some(len)) => {
-            let i8_t = ty::mk_i8();
-            fixed_vec_metadata(cx, i8_t, len, usage_site_span)
-        }
         ty::ty_enum(def_id, _) => {
             prepare_enum_metadata(cx, t, def_id, usage_site_span).finalize(cx)
         }
@@ -2200,7 +2196,7 @@ fn create_pointer_to_box_metadata(cx: &CrateContext,
                     let vec_metadata = vec_metadata(cx, mt.ty, usage_site_span);
                     pointer_type_metadata(cx, t, vec_metadata)
                 }
-                ty::ty_str(None) => {
+                ty::ty_str => {
                     let i8_t = ty::mk_i8();
                     let vec_metadata = vec_metadata(cx, i8_t, usage_site_span);
                     pointer_type_metadata(cx, t, vec_metadata)
@@ -2214,7 +2210,7 @@ fn create_pointer_to_box_metadata(cx: &CrateContext,
         ty::ty_ptr(ref mt) | ty::ty_rptr(_, ref mt) => {
             match ty::get(mt.ty).sty {
                 ty::ty_vec(ref mt, None) => vec_slice_metadata(cx, t, mt.ty, usage_site_span),
-                ty::ty_str(None) => {
+                ty::ty_str => {
                     let i8_t = ty::mk_i8();
                     vec_slice_metadata(cx, t, i8_t, usage_site_span)
                 }
index 71433d27c97a406038900a54fd9a1ac11d7af4d1..3fa5a9e085aaf6760903e613abe3432e001da265 100644 (file)
@@ -1507,7 +1507,7 @@ pub fn cast_type_kind(t: ty::t) -> cast_kind {
         ty::ty_float(..)   => cast_float,
         ty::ty_ptr(..)     => cast_pointer,
         ty::ty_rptr(_, mt) => match ty::get(mt.ty).sty{
-            ty::ty_vec(_, None) | ty::ty_str(None) => cast_other,
+            ty::ty_vec(_, None) | ty::ty_str => cast_other,
             _ => cast_pointer,
         },
         ty::ty_bare_fn(..) => cast_pointer,
@@ -1717,7 +1717,7 @@ fn deref_once<'a>(bcx: &'a Block<'a>,
     let r = match ty::get(datum.ty).sty {
         ty::ty_uniq(content_ty) => {
             match ty::get(content_ty).sty {
-                ty::ty_vec(_, None) | ty::ty_str(None)
+                ty::ty_vec(_, None) | ty::ty_str
                     => bcx.tcx().sess.span_bug(expr.span, "unexpected ~[T]"),
                 _ => deref_owned_pointer(bcx, expr, datum, content_ty),
             }
@@ -1735,7 +1735,7 @@ fn deref_once<'a>(bcx: &'a Block<'a>,
         ty::ty_ptr(ty::mt { ty: content_ty, .. }) |
         ty::ty_rptr(_, ty::mt { ty: content_ty, .. }) => {
             match ty::get(content_ty).sty {
-                ty::ty_vec(_, None) | ty::ty_str(None)
+                ty::ty_vec(_, None) | ty::ty_str
                     => bcx.tcx().sess.span_bug(expr.span, "unexpected &[T]"),
                 _ => {
                     assert!(!ty::type_needs_drop(bcx.tcx(), datum.ty));
index 4039bfaa9290839850484ce0a0997593cda786f9..37a387a558fdf4ad70611cf150cba570e3705f5a 100644 (file)
@@ -84,7 +84,7 @@ fn get_drop_glue_type(ccx: &CrateContext, t: ty::t) -> ty::t {
 
         ty::ty_uniq(typ) if !ty::type_needs_drop(tcx, typ) => {
             match ty::get(typ).sty {
-                ty::ty_vec(_, None) | ty::ty_str(None) => t,
+                ty::ty_vec(_, None) | ty::ty_str => t,
                 _ => {
                     let llty = sizing_type_of(ccx, typ);
                     // Unique boxes do not allocate for zero-size types. The standard
@@ -288,7 +288,7 @@ fn make_drop_glue<'a>(bcx: &'a Block<'a>, v0: ValueRef, t: ty::t) -> &'a Block<'
                         trans_exchange_free(bcx, llbox)
                     })
                 }
-                ty::ty_str(None) => {
+                ty::ty_str => {
                     with_cond(bcx, not_null, |bcx| {
                         let unit_ty = ty::sequence_element_type(bcx.tcx(), t);
                         let bcx = tvec::make_drop_glue_unboxed(bcx, llbox, unit_ty);
index 82f156a8bcd763a9ef9a4da25fbea7365d64041b..edf770d9cf6f808adc42efbb1b318cd19292c5c4 100644 (file)
@@ -150,17 +150,13 @@ pub fn visit_ty(&mut self, t: ty::t) {
           ty::ty_float(ast::TyF64) => self.leaf("f64"),
           ty::ty_float(ast::TyF128) => self.leaf("f128"),
 
-          // Should rename to str_*/vec_*.
-          ty::ty_str(Some(n)) => {
-              let extra = (vec!(self.c_uint(n))).append(self.c_size_and_align(t).as_slice());
-              self.visit("estr_fixed".to_owned(), extra.as_slice())
-          }
+          // Should rename to vec_*.
           ty::ty_vec(ref mt, Some(sz)) => {
               let extra = (vec!(self.c_uint(sz))).append(self.c_size_and_align(t).as_slice());
               let extra = extra.append(self.c_mt(mt).as_slice());
               self.visit("evec_fixed".to_owned(), extra.as_slice())
           }
-          ty::ty_vec(..) | ty::ty_str(..) => fail!("unexpected unsized type"),
+          ty::ty_vec(..) | ty::ty_str => fail!("unexpected unsized type"),
           // Should remove mt from box and uniq.
           ty::ty_box(typ) => {
               let extra = self.c_mt(&ty::mt {
@@ -176,7 +172,7 @@ pub fn visit_ty(&mut self, t: ty::t) {
                       let extra = extra.append(self.c_mt(mt).as_slice());
                       self.visit("evec_uniq".to_owned(), extra.as_slice())
                   }
-                  ty::ty_str(None) => self.visit("estr_uniq".to_owned(), &[]),
+                  ty::ty_str => self.visit("estr_uniq".to_owned(), &[]),
                   _ => {
                       let extra = self.c_mt(&ty::mt {
                           ty: typ,
@@ -197,7 +193,7 @@ pub fn visit_ty(&mut self, t: ty::t) {
                       let extra = extra.append(self.c_mt(mt).as_slice());
                       self.visit(~"evec_" + name, extra.as_slice())
                   }
-                  ty::ty_str(None) => self.visit("estr_slice".to_owned(), &[]),
+                  ty::ty_str => self.visit("estr_slice".to_owned(), &[]),
                   _ => {
                       let extra = self.c_mt(mt);
                       self.visit("rptr", extra.as_slice())
index 435ed53d55d5efdc4aeae6a2eabffd49139747b7..e210437a370cbcc906e47176a2bbb156d3bfd751 100644 (file)
@@ -244,7 +244,7 @@ pub fn trans_uniq_vstore<'a>(bcx: &'a Block<'a>,
                     let llptrval = C_cstr(ccx, (*s).clone(), false);
                     let llptrval = PointerCast(bcx, llptrval, Type::i8p(ccx));
                     let llsizeval = C_uint(ccx, s.get().len());
-                    let typ = ty::mk_uniq(bcx.tcx(), ty::mk_str(bcx.tcx(), None));
+                    let typ = ty::mk_uniq(bcx.tcx(), ty::mk_str(bcx.tcx()));
                     let lldestval = rvalue_scratch_datum(bcx,
                                                          typ,
                                                          "");
@@ -478,13 +478,12 @@ pub fn get_base_and_len(bcx: &Block,
     let ccx = bcx.ccx();
 
     match ty::get(vec_ty).sty {
-        ty::ty_str(Some(n)) |
         ty::ty_vec(_, Some(n)) => {
             let base = GEPi(bcx, llval, [0u, 0u]);
             (base, C_uint(ccx, n))
         }
         ty::ty_rptr(_, mt) => match ty::get(mt.ty).sty {
-            ty::ty_vec(_, None) | ty::ty_str(None) => {
+            ty::ty_vec(_, None) | ty::ty_str => {
                 assert!(!type_is_immediate(bcx.ccx(), vec_ty));
                 let base = Load(bcx, GEPi(bcx, llval, [0u, abi::slice_elt_base]));
                 let count = Load(bcx, GEPi(bcx, llval, [0u, abi::slice_elt_len]));
@@ -493,7 +492,7 @@ pub fn get_base_and_len(bcx: &Block,
             _ => ccx.sess().bug("unexpected type (ty_rptr) in get_base_and_len"),
         },
         ty::ty_uniq(t) => match ty::get(t).sty {
-            ty::ty_vec(_, None) | ty::ty_str(None) => {
+            ty::ty_vec(_, None) | ty::ty_str => {
                 assert!(type_is_immediate(bcx.ccx(), vec_ty));
                 let vt = vec_types(bcx, ty::sequence_element_type(bcx.tcx(), vec_ty));
                 let body = Load(bcx, llval);
index e52c890c93eb8926c5b85e246e6382bf0f758ea4..7e3890cec856233b3d3f2ad18d8fe76fde91fb0e 100644 (file)
@@ -121,7 +121,7 @@ pub fn sizing_type_of(cx: &CrateContext, t: ty::t) -> Type {
         ty::ty_ptr(..) => Type::i8p(cx),
         ty::ty_rptr(_, mt) => {
             match ty::get(mt.ty).sty {
-                ty::ty_vec(_, None) | ty::ty_str(None) => {
+                ty::ty_vec(_, None) | ty::ty_str => {
                     Type::struct_(cx, [Type::i8p(cx), Type::i8p(cx)], false)
                 }
                 _ => Type::i8p(cx),
@@ -132,7 +132,6 @@ pub fn sizing_type_of(cx: &CrateContext, t: ty::t) -> Type {
         ty::ty_closure(..) => Type::struct_(cx, [Type::i8p(cx), Type::i8p(cx)], false),
         ty::ty_trait(..) => Type::opaque_trait(cx),
 
-        ty::ty_str(Some(size)) => Type::array(&Type::i8(cx), size as u64),
         ty::ty_vec(mt, Some(size)) => {
             Type::array(&sizing_type_of(cx, mt.ty), size as u64)
         }
@@ -154,7 +153,7 @@ pub fn sizing_type_of(cx: &CrateContext, t: ty::t) -> Type {
         }
 
         ty::ty_self(_) | ty::ty_infer(..) | ty::ty_param(..) |
-        ty::ty_err(..) | ty::ty_vec(_, None) | ty::ty_str(None) => {
+        ty::ty_err(..) | ty::ty_vec(_, None) | ty::ty_str => {
             cx.sess().bug(format!("fictitious type {:?} in sizing_type_of()",
                                   ty::get(t).sty))
         }
@@ -215,7 +214,7 @@ pub fn type_of(cx: &CrateContext, t: ty::t) -> Type {
       ty::ty_uniq(typ) => {
           match ty::get(typ).sty {
               ty::ty_vec(mt, None) => Type::vec(cx, &type_of(cx, mt.ty)).ptr_to(),
-              ty::ty_str(None) => Type::vec(cx, &Type::i8(cx)).ptr_to(),
+              ty::ty_str => Type::vec(cx, &Type::i8(cx)).ptr_to(),
               _ => type_of(cx, typ).ptr_to(),
           }
       }
@@ -227,7 +226,7 @@ pub fn type_of(cx: &CrateContext, t: ty::t) -> Type {
                   let u_ty = Type::uint_from_ty(cx, ast::TyU);
                   Type::struct_(cx, [p_ty, u_ty], false)
               }
-              ty::ty_str(None) => {
+              ty::ty_str => {
                   // This means we get a nicer name in the output
                   cx.tn.find_type("str_slice").unwrap()
               }
@@ -235,10 +234,6 @@ pub fn type_of(cx: &CrateContext, t: ty::t) -> Type {
           }
       }
 
-      ty::ty_str(Some(n)) => {
-          Type::array(&Type::i8(cx), (n + 1u) as u64)
-      }
-
       ty::ty_vec(ref mt, Some(n)) => {
           Type::array(&type_of(cx, mt.ty), n as u64)
       }
@@ -274,7 +269,7 @@ pub fn type_of(cx: &CrateContext, t: ty::t) -> Type {
       }
 
       ty::ty_vec(_, None) => cx.sess().bug("type_of with unsized ty_vec"),
-      ty::ty_str(None) => cx.sess().bug("type_of with unsized ty_str"),
+      ty::ty_str => cx.sess().bug("type_of with unsized (bare) ty_str"),
       ty::ty_self(..) => cx.sess().unimpl("type_of with ty_self"),
       ty::ty_infer(..) => cx.sess().bug("type_of with ty_infer"),
       ty::ty_param(..) => cx.sess().bug("type_of with ty_param"),
index b87337fa240d6800b042b7e8c27ba84f3be30666..459310bd94b479ddaf71e29858b88130f677a039 100644 (file)
@@ -726,9 +726,8 @@ pub enum sty {
     ty_enum(DefId, substs),
     ty_box(t),
     ty_uniq(t),
-    // ty_str and ty_vec have an optional length.
-    ty_str(Option<uint>),
-    ty_vec(mt, Option<uint>),
+    ty_str,
+    ty_vec(mt, Option<uint>),  // Second field is length.
     ty_ptr(mt),
     ty_rptr(Region, mt),
     ty_bare_fn(BareFnTy),
@@ -1175,7 +1174,7 @@ fn sflags(substs: &substs) -> uint {
     }
     match &st {
       &ty_nil | &ty_bool | &ty_char | &ty_int(_) | &ty_float(_) | &ty_uint(_) |
-      &ty_str(_) => {}
+      &ty_str => {}
       // You might think that we could just return ty_err for
       // any type containing ty_err as a component, and get
       // rid of the has_ty_err flag -- likewise for ty_bot (with
@@ -1341,14 +1340,14 @@ pub fn mk_mach_float(tm: ast::FloatTy) -> t {
 #[inline]
 pub fn mk_char() -> t { mk_prim_t(&primitives::TY_CHAR) }
 
-pub fn mk_str(cx: &ctxt, sz: Option<uint>) -> t {
-    mk_t(cx, ty_str(sz))
+pub fn mk_str(cx: &ctxt) -> t {
+    mk_t(cx, ty_str)
 }
 
 pub fn mk_str_slice(cx: &ctxt, r: Region, m: ast::Mutability) -> t {
     mk_rptr(cx, r,
             mt {
-                ty: mk_t(cx, ty_str(None)),
+                ty: mk_t(cx, ty_str),
                 mutbl: m
             })
 }
@@ -1471,7 +1470,7 @@ pub fn maybe_walk_ty(ty: t, f: |t| -> bool) {
     }
     match get(ty).sty {
         ty_nil | ty_bot | ty_bool | ty_char | ty_int(_) | ty_uint(_) | ty_float(_) |
-        ty_str(_) | ty_self(_) |
+        ty_str | ty_self(_) |
         ty_infer(_) | ty_param(_) | ty_err => {}
         ty_box(ty) | ty_uniq(ty) => maybe_walk_ty(ty, f),
         ty_ptr(ref tm) | ty_rptr(_, ref tm) | ty_vec(ref tm, _) => {
@@ -1612,7 +1611,7 @@ pub fn type_is_self(ty: t) -> bool {
 fn type_is_slice(ty:t) -> bool {
     match get(ty).sty {
         ty_rptr(_, mt) => match get(mt.ty).sty {
-            ty_vec(_, None) | ty_str(None) => true,
+            ty_vec(_, None) | ty_str => true,
             _ => false,
         },
         _ => false
@@ -1622,8 +1621,7 @@ fn type_is_slice(ty:t) -> bool {
 pub fn type_is_structural(ty: t) -> bool {
     match get(ty).sty {
       ty_struct(..) | ty_tup(_) | ty_enum(..) | ty_closure(_) | ty_trait(..) |
-      ty_vec(_, Some(_)) |
-      ty_str(Some(_)) => true,
+      ty_vec(_, Some(_)) => true,
       _ => type_is_slice(ty)
     }
 }
@@ -1637,12 +1635,11 @@ pub fn type_is_simd(cx: &ctxt, ty: t) -> bool {
 
 pub fn sequence_element_type(cx: &ctxt, ty: t) -> t {
     match get(ty).sty {
-        ty_str(Some(_)) => mk_mach_uint(ast::TyU8),
         ty_vec(mt, Some(_)) => mt.ty,
         ty_ptr(mt{ty: t, ..}) | ty_rptr(_, mt{ty: t, ..}) |
         ty_box(t) | ty_uniq(t) => match get(t).sty {
             ty_vec(mt, None) => mt.ty,
-            ty_str(None) => mk_mach_uint(ast::TyU8),
+            ty_str => mk_mach_uint(ast::TyU8),
             _ => cx.sess.bug("sequence_element_type called on non-sequence value"),
         },
         _ => cx.sess.bug("sequence_element_type called on non-sequence value"),
@@ -1681,7 +1678,7 @@ pub fn type_is_region_ptr(ty: t) -> bool {
         ty_rptr(_, mt) => match get(mt.ty).sty {
             // FIXME(nrc, DST) slices weren't regarded as rptrs, so we preserve this
             // odd behaviour for now. (But ~[] were unique. I have no idea why).
-            ty_vec(_, None) | ty_str(None) => false,
+            ty_vec(_, None) | ty_str => false,
             _ => true
         },
         _ => false
@@ -2079,7 +2076,7 @@ fn tc_ty(cx: &ctxt,
         let result = match get(ty).sty {
             // Scalar and unique types are sendable, and durable
             ty_nil | ty_bot | ty_bool | ty_int(_) | ty_uint(_) | ty_float(_) |
-            ty_bare_fn(_) | ty::ty_char => {
+            ty_bare_fn(_) | ty::ty_char | ty_str => {
                 TC::None
             }
 
@@ -2093,7 +2090,7 @@ fn tc_ty(cx: &ctxt,
 
             ty_uniq(typ) => {
                 match get(typ).sty {
-                    ty_str(None) => TC::OwnsOwned,
+                    ty_str => TC::OwnsOwned,
                     _ => tc_ty(cx, typ, cache).owned_pointer(),
                 }
             }
@@ -2108,7 +2105,7 @@ fn tc_ty(cx: &ctxt,
 
             ty_rptr(r, ref mt) => {
                 match get(mt.ty).sty {
-                    ty_str(None) => borrowed_contents(r, ast::MutImmutable),
+                    ty_str => borrowed_contents(r, ast::MutImmutable),
                     _ => tc_ty(cx, mt.ty, cache).reference(borrowed_contents(r, mt.mutbl)),
                 }
             }
@@ -2117,10 +2114,6 @@ fn tc_ty(cx: &ctxt,
                 tc_mt(cx, mt, cache)
             }
 
-            ty_str(_) => {
-                TC::None
-            }
-
             ty_struct(did, ref substs) => {
                 let flds = struct_fields(cx, did, substs);
                 let mut res =
@@ -2348,7 +2341,7 @@ fn subtypes_require(cx: &ctxt, seen: &mut Vec<DefId>,
             ty_int(_) |
             ty_uint(_) |
             ty_float(_) |
-            ty_str(_) |
+            ty_str |
             ty_bare_fn(_) |
             ty_closure(_) |
             ty_infer(_) |
@@ -2612,7 +2605,7 @@ pub fn deref(t: t, explicit: bool) -> Option<mt> {
     match get(t).sty {
         ty_box(typ) | ty_uniq(typ) => match get(typ).sty {
             // Don't deref ~[] etc., might need to generalise this to all DST.
-            ty_vec(_, None) | ty_str(None) => None,
+            ty_vec(_, None) | ty_str => None,
             _ => Some(mt {
                 ty: typ,
                 mutbl: ast::MutImmutable,
@@ -2620,7 +2613,7 @@ pub fn deref(t: t, explicit: bool) -> Option<mt> {
         },
         ty_rptr(_, mt) => match get(mt.ty).sty {
             // Don't deref &[], might need to generalise this to all DST.
-            ty_vec(_, None) | ty_str(None) => None,
+            ty_vec(_, None) | ty_str => None,
             _ => Some(mt),
         },
         ty_ptr(mt) if explicit => Some(mt),
@@ -2635,10 +2628,9 @@ pub fn index(t: t) -> Option<mt> {
         ty_ptr(mt{ty: t, ..}) | ty_rptr(_, mt{ty: t, ..}) |
         ty_box(t) | ty_uniq(t) => match get(t).sty {
             ty_vec(mt, None) => Some(mt),
-            ty_str(None) => Some(mt {ty: mk_u8(), mutbl: ast::MutImmutable}),
+            ty_str => Some(mt {ty: mk_u8(), mutbl: ast::MutImmutable}),
             _ => None,
         },
-        ty_str(Some(_)) => Some(mt {ty: mk_u8(), mutbl: ast::MutImmutable}),
         _ => None
     }
 }
@@ -2948,7 +2940,7 @@ fn borrow_vec(cx: &ctxt,
             ty_uniq(t) | ty_ptr(mt{ty: t, ..}) |
             ty_rptr(_, mt{ty: t, ..}) => match get(t).sty {
                 ty::ty_vec(mt, None) => ty::mk_slice(cx, r, ty::mt {ty: mt.ty, mutbl: m}),
-                ty::ty_str(None) => ty::mk_str_slice(cx, r, m),
+                ty::ty_str => ty::mk_str_slice(cx, r, m),
                 _ => {
                     cx.sess.span_bug(
                         span,
@@ -2956,7 +2948,6 @@ fn borrow_vec(cx: &ctxt,
                 }
             },
             ty_vec(mt, Some(_)) => ty::mk_slice(cx, r, ty::mt {ty: mt.ty, mutbl: m}),
-            ty_str(Some(_)) => ty::mk_str_slice(cx, r, m),
 
             ref s => {
                 cx.sess.span_bug(
@@ -3262,7 +3253,7 @@ pub fn param_tys_in_type(ty: t) -> Vec<param_ty> {
 pub fn ty_sort_str(cx: &ctxt, t: t) -> ~str {
     match get(t).sty {
         ty_nil | ty_bot | ty_bool | ty_char | ty_int(_) |
-        ty_uint(_) | ty_float(_) | ty_str(_) => {
+        ty_uint(_) | ty_float(_) | ty_str => {
             ::util::ppaux::ty_to_str(cx, t)
         }
 
@@ -4528,13 +4519,8 @@ pub fn hash_crate_independent(tcx: &ctxt, t: t, svh: &Svh) -> u64 {
                 byte!(6);
                 hash!(f);
             }
-            ty_str(Some(_)) => {
+            ty_str => {
                 byte!(7);
-                1u8.hash(&mut state);
-            }
-            ty_str(None) => {
-                byte!(7);
-                0u8.hash(&mut state);
             }
             ty_enum(d, _) => {
                 byte!(8);
index bfce00a718b8c022832ee8db286ec6a169875d37..a4cc9f0cc2f2acfc8d9a6af8938a95766e690f71 100644 (file)
@@ -175,10 +175,7 @@ pub fn super_fold_sty<T:TypeFolder>(this: &mut T,
             ty::ty_struct(did,
                           this.fold_substs(substs))
         }
-        ty::ty_str(sz) => {
-            ty::ty_str(sz)
-        }
-        ty::ty_nil | ty::ty_bot | ty::ty_bool | ty::ty_char |
+        ty::ty_nil | ty::ty_bot | ty::ty_bool | ty::ty_char | ty::ty_str |
         ty::ty_int(_) | ty::ty_uint(_) | ty::ty_float(_) |
         ty::ty_err | ty::ty_infer(_) |
         ty::ty_param(..) | ty::ty_self(_) => {
index 66e640cbcd6bfc9d57602858236ca7851af8989a..77f339ec10e24f58d72ad8779cc7b36aff5b6ec9 100644 (file)
@@ -355,7 +355,7 @@ pub fn ast_ty_to_prim_ty(tcx: &ty::ctxt, ast_ty: &ast::Ty) -> Option<ty::t> {
                             tcx.sess.span_err(ast_ty.span,
                                               "bare `str` is not a type");
                             // return /something/ so they can at least get more errors
-                            Some(ty::mk_uniq(tcx, ty::mk_str(tcx, None)))
+                            Some(ty::mk_uniq(tcx, ty::mk_str(tcx)))
                         }
                     }
                 }
@@ -414,7 +414,7 @@ fn mk_pointer<AC:AstConv,
                         check_path_args(tcx, path, NO_TPS | NO_REGIONS);
                         match ptr_ty {
                             Uniq => {
-                                return ty::mk_uniq(tcx, ty::mk_str(tcx, None));
+                                return ty::mk_uniq(tcx, ty::mk_str(tcx));
                             }
                             RPtr(r) => {
                                 return ty::mk_str_slice(tcx, r, ast::MutImmutable);
index 16389771bb429e0908977201ea52e57bc800a2f8..52e0deddf3c792c6e62cee13c62aa7579654fcd9 100644 (file)
@@ -769,7 +769,7 @@ fn consider_reborrow(&self,
                     self.infcx().next_region_var(infer::Autoref(self.span));
                 let (extra_derefs, auto) = match ty::get(self_mt.ty).sty {
                     ty::ty_vec(_, None) => (0, ty::AutoBorrowVec(region, self_mt.mutbl)),
-                    ty::ty_str(None) => (0, ty::AutoBorrowVec(region, self_mt.mutbl)),
+                    ty::ty_str => (0, ty::AutoBorrowVec(region, self_mt.mutbl)),
                     _ => (1, ty::AutoPtr(region, self_mt.mutbl)),
                 };
                 (ty::mk_rptr(tcx, region, self_mt),
@@ -878,11 +878,10 @@ fn search_for_autosliced_method(&self,
             },
             ty_uniq(t) => match ty::get(t).sty {
                 ty_vec(mt, None) => self.auto_slice_vec(mt, autoderefs),
-                ty_str(None) => self.auto_slice_str(autoderefs),
+                ty_str => self.auto_slice_str(autoderefs),
                 _ => None
             },
             ty_vec(mt, Some(_)) => self.auto_slice_vec(mt, autoderefs),
-            ty_str(Some(_)) => self.auto_slice_str(autoderefs),
 
             ty_trait(~ty::TyTrait { def_id: trt_did, substs: trt_substs, bounds: b, .. }) => {
                 // Coerce ~/&Trait instances to &Trait.
@@ -921,7 +920,7 @@ fn search_for_autoptrd_method(&self, self_ty: ty::t, autoderefs: uint)
             ty_self(_) | ty_param(..) | ty_nil | ty_bot | ty_bool |
             ty_char | ty_int(..) | ty_uint(..) |
             ty_float(..) | ty_enum(..) | ty_ptr(..) | ty_struct(..) | ty_tup(..) |
-            ty_str(..) | ty_vec(..) | ty_trait(..) | ty_closure(..) => {
+            ty_str | ty_vec(..) | ty_trait(..) | ty_closure(..) => {
                 self.search_for_some_kind_of_autorefd_method(
                     AutoPtr, autoderefs, [MutImmutable, MutMutable],
                     |m,r| ty::mk_rptr(tcx, r, ty::mt {ty:self_ty, mutbl:m}))
@@ -1318,7 +1317,7 @@ fn is_relevant(&self, rcvr_ty: ty::t, candidate: &Candidate) -> bool {
                 match ty::get(rcvr_ty).sty {
                     ty::ty_rptr(_, mt) => {
                         match ty::get(mt.ty).sty {
-                            ty::ty_vec(_, None) | ty::ty_str(None) => false,
+                            ty::ty_vec(_, None) | ty::ty_str => false,
                             _ => mutability_matches(mt.mutbl, m) &&
                                  rcvr_matches_ty(self.fcx, mt.ty, candidate),
                         }
@@ -1340,7 +1339,7 @@ fn is_relevant(&self, rcvr_ty: ty::t, candidate: &Candidate) -> bool {
                 match ty::get(rcvr_ty).sty {
                     ty::ty_uniq(typ) => {
                         match ty::get(typ).sty {
-                            ty::ty_vec(_, None) | ty::ty_str(None) => false,
+                            ty::ty_vec(_, None) | ty::ty_str => false,
                             _ => rcvr_matches_ty(self.fcx, typ, candidate),
                         }
                     }
index b6ea33a9fdf4c28b80b8ff8537c844a15bba4ebd..a0847baaea2855749b32b6e1c298cee2ab682a90 100644 (file)
@@ -2567,7 +2567,7 @@ fn check_struct_enum_variant(fcx: &FnCtxt,
       ast::ExprVstore(ev, vst) => {
         let typ = match ev.node {
           ast::ExprLit(lit) if ast_util::lit_is_str(lit) => {
-            ast_expr_vstore_to_ty(fcx, ev, vst, || ty::mt{ ty: ty::mk_str(tcx, None),
+            ast_expr_vstore_to_ty(fcx, ev, vst, || ty::mt{ ty: ty::mk_str(tcx),
                                                            mutbl: ast::MutImmutable })
           }
           ast::ExprVec(ref args) => {
index e679718c931aad64e7a6b25c6743e80e5ff19413..5cd48c5c83d68c157ce8f9002ffb14e929d84b94 100644 (file)
@@ -940,7 +940,7 @@ fn constrain_index(rcx: &mut Rcx,
     let r_index_expr = ty::ReScope(index_expr.id);
     match ty::get(indexed_ty).sty {
         ty::ty_rptr(r_ptr, mt) => match ty::get(mt.ty).sty {
-            ty::ty_vec(_, None) | ty::ty_str(None)=> {
+            ty::ty_vec(_, None) | ty::ty_str => {
                 rcx.fcx.mk_subr(true, infer::IndexSlice(index_expr.span),
                                 r_index_expr, r_ptr);
             }
index aba9c62d83dd076f26f5f13176821893697953d4..aa00b24474f9cb5f487503fdb6e4fe56f44e58de 100644 (file)
@@ -108,7 +108,7 @@ pub fn tys(&self, a: ty::t, b: ty::t) -> CoerceResult {
                         });
                     }
                     ty::ty_vec(_, _) => {},
-                    ty::ty_str(None) => {
+                    ty::ty_str => {
                         return self.unpack_actual_value(a, |sty_a| {
                             self.coerce_borrowed_string(a, sty_a, b)
                         });
@@ -263,7 +263,7 @@ pub fn coerce_borrowed_string(&self,
 
         match *sty_a {
             ty::ty_uniq(t) => match ty::get(t).sty {
-                ty::ty_str(None) => {}
+                ty::ty_str => {}
                 _ => return self.subtype(a, b),
             },
             _ => {
index 235fb7d496e207f9772787bb589fd07b6b17d608..b5e15a32b1ca3b78d32deda39ecbfb313a53b102 100644 (file)
@@ -383,9 +383,9 @@ fn check_ptr_to_vec<C:Combine>(this: &C,
                                    result: ty::t) -> cres<ty::t> {
         match (&ty::get(a_inner).sty, &ty::get(b_inner).sty) {
             (&ty::ty_vec(_, None), &ty::ty_vec(_, None)) |
-            (&ty::ty_str(None), &ty::ty_str(None)) => Ok(result),
+            (&ty::ty_str, &ty::ty_str) => Ok(result),
             (&ty::ty_vec(_, None), _) | (_, &ty::ty_vec(_, None)) |
-            (&ty::ty_str(None), _) | (_, &ty::ty_str(None))
+            (&ty::ty_str, _) | (_, &ty::ty_str)
                 => Err(ty::terr_sorts(expected_found(this, a, b))),
             _ => Ok(result),
         }
@@ -520,12 +520,8 @@ fn check_ptr_to_vec<C:Combine>(this: &C,
         })
       }
 
-      (&ty::ty_str(sz_a), &ty::ty_str(sz_b)) => {
-            if sz_a == sz_b {
-                Ok(ty::mk_str(tcx,sz_a))
-            } else {
-                Err(ty::terr_sorts(expected_found(this, a, b)))
-            }
+      (&ty::ty_str, &ty::ty_str) => {
+            Ok(ty::mk_str(tcx))
       }
 
       (&ty::ty_tup(ref as_), &ty::ty_tup(ref bs)) => {
index a44c70e5df8a4b2243bd3d0bc2c02d2ed799cf01..a4fae2d9aa4f20f376a59535f15dc9a57f385b96 100644 (file)
@@ -706,7 +706,7 @@ fn add_constraints_from_ty(&mut self,
         match ty::get(ty).sty {
             ty::ty_nil | ty::ty_bot | ty::ty_bool |
             ty::ty_char | ty::ty_int(_) | ty::ty_uint(_) |
-            ty::ty_float(_) | ty::ty_str(_) => {
+            ty::ty_float(_) | ty::ty_str => {
                 /* leaf type -- noop */
             }
 
index 7c36885407d11485597b1854dd6bac9949c0fcc0..06adce194f1677430d43f02fda7d59e98502bdf8 100644 (file)
@@ -395,12 +395,7 @@ fn push_sig_to_str(cx: &ctxt,
         let bound_str = bounds.repr(cx);
         format!("{}{}{}{}", trait_store_to_str(cx, store), ty, bound_sep, bound_str)
       }
-      ty_str(sz) => {
-        match sz {
-            Some(n) => format!("str/{}", n),
-            None => "str".to_owned(),
-        }
-      }
+      ty_str => "str".to_owned(),
       ty_vec(ref mt, sz) => {
           match sz {
               Some(n) => format!("[{}, .. {}]", mt_to_str(cx, mt), n),