Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove internal support for fixed length strings #13834

Merged
merged 1 commit into from
Apr 29, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/librustc/metadata/tydecode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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), '[');
Expand Down
7 changes: 1 addition & 6 deletions src/librustc/metadata/tyencode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/check_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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, _) => {
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/effect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,13 @@ impl<'a> EffectCheckVisitor<'a> {
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");
}
Expand Down
6 changes: 2 additions & 4 deletions src/librustc/middle/mem_categorization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))))
}

Expand Down Expand Up @@ -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
}
}
5 changes: 2 additions & 3 deletions src/librustc/middle/trans/_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1316,7 +1316,7 @@ fn compare_values<'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");
Expand All @@ -1333,10 +1333,9 @@ fn compare_values<'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"),
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/trans/adt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ impl Case {
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(..) |
Expand Down
5 changes: 0 additions & 5 deletions src/librustc/middle/trans/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -664,11 +664,6 @@ pub fn iter_structural_ty<'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);
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/trans/callee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
},
_ => {}
Expand Down
10 changes: 3 additions & 7 deletions src/librustc/middle/trans/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
}
Expand Down Expand Up @@ -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]))
},
Expand All @@ -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 {
Expand Down
8 changes: 2 additions & 6 deletions src/librustc/middle/trans/debuginfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2183,10 +2183,6 @@ fn type_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)
}
Expand All @@ -2200,7 +2196,7 @@ fn type_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)
Expand All @@ -2214,7 +2210,7 @@ fn type_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)
}
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/middle/trans/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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),
}
Expand All @@ -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));
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/trans/glue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
12 changes: 4 additions & 8 deletions src/librustc/middle/trans/reflect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,17 +150,13 @@ impl<'a, 'b> Reflector<'a, 'b> {
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 {
Expand All @@ -176,7 +172,7 @@ impl<'a, 'b> Reflector<'a, 'b> {
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,
Expand All @@ -197,7 +193,7 @@ impl<'a, 'b> Reflector<'a, 'b> {
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())
Expand Down
7 changes: 3 additions & 4 deletions src/librustc/middle/trans/tvec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
"");
Expand Down Expand Up @@ -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]));
Expand All @@ -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);
Expand Down
15 changes: 5 additions & 10 deletions src/librustc/middle/trans/type_of.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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)
}
Expand All @@ -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))
}
Expand Down Expand Up @@ -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(),
}
}
Expand All @@ -227,18 +226,14 @@ 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()
}
_ => type_of(cx, mt.ty).ptr_to(),
}
}

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)
}
Expand Down Expand Up @@ -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"),
Expand Down
Loading