Skip to content

Commit f3c3389

Browse files
committed
Remove internal support for fixed length strings
1 parent a3b28cb commit f3c3389

26 files changed

+72
-131
lines changed

src/librustc/metadata/tydecode.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -344,8 +344,7 @@ fn parse_ty(st: &mut PState, conv: conv_did) -> ty::t {
344344
return ty::mk_vec(st.tcx, mt, sz);
345345
}
346346
'v' => {
347-
let sz = parse_size(st);
348-
return ty::mk_str(st.tcx, sz);
347+
return ty::mk_str(st.tcx);
349348
}
350349
'T' => {
351350
assert_eq!(next(st), '[');

src/librustc/metadata/tyencode.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -260,13 +260,8 @@ fn enc_sty(w: &mut MemWriter, cx: &ctxt, st: &ty::sty) {
260260
None => mywrite!(w, "|"),
261261
}
262262
}
263-
ty::ty_str(sz) => {
263+
ty::ty_str => {
264264
mywrite!(w, "v");
265-
mywrite!(w, "/");
266-
match sz {
267-
Some(n) => mywrite!(w, "{}|", n),
268-
None => mywrite!(w, "|"),
269-
}
270265
}
271266
ty::ty_closure(ref f) => {
272267
mywrite!(w, "f");

src/librustc/middle/check_match.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ fn missing_ctor(cx: &MatchCheckCtxt,
405405
ty::ty_struct(..) => check_matrix_for_wild(cx, m),
406406
ty::ty_uniq(ty) | ty::ty_rptr(_, ty::mt{ty: ty, ..}) => match ty::get(ty).sty {
407407
ty::ty_vec(_, None) => ctor_for_slice(m),
408-
ty::ty_str(None) => Some(single),
408+
ty::ty_str => Some(single),
409409
_ => check_matrix_for_wild(cx, m),
410410
},
411411
ty::ty_enum(eid, _) => {

src/librustc/middle/effect.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,13 @@ impl<'a> EffectCheckVisitor<'a> {
6969
ppaux::ty_to_str(self.tcx, base_type));
7070
match ty::get(base_type).sty {
7171
ty::ty_uniq(ty) | ty::ty_rptr(_, ty::mt{ty, ..}) => match ty::get(ty).sty {
72-
ty::ty_str(None) => {
72+
ty::ty_str => {
7373
self.tcx.sess.span_err(e.span,
7474
"modification of string types is not allowed");
7575
}
7676
_ => {}
7777
},
78-
ty::ty_str(..) => {
78+
ty::ty_str => {
7979
self.tcx.sess.span_err(e.span,
8080
"modification of string types is not allowed");
8181
}

src/librustc/middle/mem_categorization.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,7 @@ pub fn opt_deref_kind(t: ty::t) -> Option<deref_kind> {
204204
Some(deref_interior(InteriorField(PositionalField(0))))
205205
}
206206

207-
ty::ty_vec(_, Some(_)) |
208-
ty::ty_str(Some(_)) => {
207+
ty::ty_vec(_, Some(_)) => {
209208
Some(deref_interior(InteriorElement(element_kind(t))))
210209
}
211210

@@ -1304,11 +1303,10 @@ fn element_kind(t: ty::t) -> ElementKind {
13041303
ty::ty_rptr(_, ty::mt{ty:ty, ..}) |
13051304
ty::ty_uniq(ty) => match ty::get(ty).sty {
13061305
ty::ty_vec(_, None) => VecElement,
1307-
ty::ty_str(None) => StrElement,
1306+
ty::ty_str => StrElement,
13081307
_ => OtherElement
13091308
},
13101309
ty::ty_vec(..) => VecElement,
1311-
ty::ty_str(..) => StrElement,
13121310
_ => OtherElement
13131311
}
13141312
}

src/librustc/middle/trans/_match.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1316,7 +1316,7 @@ fn compare_values<'a>(
13161316

13171317
match ty::get(rhs_t).sty {
13181318
ty::ty_uniq(t) => match ty::get(t).sty {
1319-
ty::ty_str(None) => {
1319+
ty::ty_str => {
13201320
let scratch_lhs = alloca(cx, val_ty(lhs), "__lhs");
13211321
Store(cx, lhs, scratch_lhs);
13221322
let scratch_rhs = alloca(cx, val_ty(rhs), "__rhs");
@@ -1333,10 +1333,9 @@ fn compare_values<'a>(
13331333
_ => cx.sess().bug("only scalars and strings supported in compare_values"),
13341334
},
13351335
ty::ty_rptr(_, mt) => match ty::get(mt.ty).sty {
1336-
ty::ty_str(None) => compare_str(cx, lhs, rhs, rhs_t),
1336+
ty::ty_str => compare_str(cx, lhs, rhs, rhs_t),
13371337
_ => cx.sess().bug("only scalars and strings supported in compare_values"),
13381338
},
1339-
ty::ty_str(Some(_)) => compare_str(cx, lhs, rhs, rhs_t),
13401339
_ => cx.sess().bug("only scalars and strings supported in compare_values"),
13411340
}
13421341
}

src/librustc/middle/trans/adt.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ impl Case {
270270
self.tys.iter().position(|&ty| {
271271
match ty::get(ty).sty {
272272
ty::ty_rptr(_, mt) => match ty::get(mt.ty).sty {
273-
ty::ty_vec(_, None) | ty::ty_str(None)=> false,
273+
ty::ty_vec(_, None) | ty::ty_str => false,
274274
_ => true,
275275
},
276276
ty::ty_uniq(..) | ty::ty_box(..) |

src/librustc/middle/trans/base.rs

-5
Original file line numberDiff line numberDiff line change
@@ -664,11 +664,6 @@ pub fn iter_structural_ty<'r,
664664
}
665665
})
666666
}
667-
ty::ty_str(Some(n)) => {
668-
let unit_ty = ty::sequence_element_type(cx.tcx(), t);
669-
let (base, len) = tvec::get_fixed_base_and_byte_len(cx, av, unit_ty, n);
670-
cx = tvec::iter_vec_raw(cx, base, unit_ty, len, f);
671-
}
672667
ty::ty_vec(_, Some(n)) => {
673668
let unit_ty = ty::sequence_element_type(cx.tcx(), t);
674669
let (base, len) = tvec::get_fixed_base_and_byte_len(cx, av, unit_ty, n);

src/librustc/middle/trans/callee.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,7 @@ pub fn trans_call_inner<'a>(
660660
// `~` pointer return values never alias because ownership
661661
// is transferred
662662
ty::ty_uniq(ty) => match ty::get(ty).sty {
663-
ty::ty_str(None) => {}
663+
ty::ty_str => {}
664664
_ => attrs.push((0, NoAliasAttribute)),
665665
},
666666
_ => {}

src/librustc/middle/trans/consts.rs

+3-7
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ fn const_deref(cx: &CrateContext, v: ValueRef, t: ty::t, explicit: bool)
141141
let dv = match ty::get(t).sty {
142142
ty::ty_ptr(mt) | ty::ty_rptr(_, mt) => {
143143
match ty::get(mt.ty).sty {
144-
ty::ty_vec(_, None) | ty::ty_str(None) => cx.sess().bug("unexpected slice"),
144+
ty::ty_vec(_, None) | ty::ty_str => cx.sess().bug("unexpected slice"),
145145
_ => const_deref_ptr(cx, v),
146146
}
147147
}
@@ -434,7 +434,7 @@ fn const_expr_unadjusted(cx: &CrateContext, e: &ast::Expr,
434434
let (arr, len) = match ty::get(bt).sty {
435435
ty::ty_vec(_, Some(u)) => (bv, C_uint(cx, u)),
436436
ty::ty_rptr(_, mt) => match ty::get(mt.ty).sty {
437-
ty::ty_vec(_, None) | ty::ty_str(None) => {
437+
ty::ty_vec(_, None) | ty::ty_str => {
438438
let e1 = const_get_elt(cx, bv, [0]);
439439
(const_deref_ptr(cx, e1), const_get_elt(cx, bv, [1]))
440440
},
@@ -448,16 +448,12 @@ fn const_expr_unadjusted(cx: &CrateContext, e: &ast::Expr,
448448
let len = llvm::LLVMConstIntGetZExtValue(len) as u64;
449449
let len = match ty::get(bt).sty {
450450
ty::ty_uniq(ty) | ty::ty_rptr(_, ty::mt{ty, ..}) => match ty::get(ty).sty {
451-
ty::ty_str(None) => {
451+
ty::ty_str => {
452452
assert!(len > 0);
453453
len - 1
454454
}
455455
_ => len
456456
},
457-
ty::ty_str(Some(_)) => {
458-
assert!(len > 0);
459-
len - 1
460-
},
461457
_ => len
462458
};
463459
if iv >= len {

src/librustc/middle/trans/debuginfo.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -2183,10 +2183,6 @@ fn type_metadata(cx: &CrateContext,
21832183
ty::ty_float(_) => {
21842184
basic_type_metadata(cx, t)
21852185
}
2186-
ty::ty_str(Some(len)) => {
2187-
let i8_t = ty::mk_i8();
2188-
fixed_vec_metadata(cx, i8_t, len, usage_site_span)
2189-
}
21902186
ty::ty_enum(def_id, _) => {
21912187
prepare_enum_metadata(cx, t, def_id, usage_site_span).finalize(cx)
21922188
}
@@ -2200,7 +2196,7 @@ fn type_metadata(cx: &CrateContext,
22002196
let vec_metadata = vec_metadata(cx, mt.ty, usage_site_span);
22012197
pointer_type_metadata(cx, t, vec_metadata)
22022198
}
2203-
ty::ty_str(None) => {
2199+
ty::ty_str => {
22042200
let i8_t = ty::mk_i8();
22052201
let vec_metadata = vec_metadata(cx, i8_t, usage_site_span);
22062202
pointer_type_metadata(cx, t, vec_metadata)
@@ -2214,7 +2210,7 @@ fn type_metadata(cx: &CrateContext,
22142210
ty::ty_ptr(ref mt) | ty::ty_rptr(_, ref mt) => {
22152211
match ty::get(mt.ty).sty {
22162212
ty::ty_vec(ref mt, None) => vec_slice_metadata(cx, t, mt.ty, usage_site_span),
2217-
ty::ty_str(None) => {
2213+
ty::ty_str => {
22182214
let i8_t = ty::mk_i8();
22192215
vec_slice_metadata(cx, t, i8_t, usage_site_span)
22202216
}

src/librustc/middle/trans/expr.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1507,7 +1507,7 @@ pub fn cast_type_kind(t: ty::t) -> cast_kind {
15071507
ty::ty_float(..) => cast_float,
15081508
ty::ty_ptr(..) => cast_pointer,
15091509
ty::ty_rptr(_, mt) => match ty::get(mt.ty).sty{
1510-
ty::ty_vec(_, None) | ty::ty_str(None) => cast_other,
1510+
ty::ty_vec(_, None) | ty::ty_str => cast_other,
15111511
_ => cast_pointer,
15121512
},
15131513
ty::ty_bare_fn(..) => cast_pointer,
@@ -1717,7 +1717,7 @@ fn deref_once<'a>(bcx: &'a Block<'a>,
17171717
let r = match ty::get(datum.ty).sty {
17181718
ty::ty_uniq(content_ty) => {
17191719
match ty::get(content_ty).sty {
1720-
ty::ty_vec(_, None) | ty::ty_str(None)
1720+
ty::ty_vec(_, None) | ty::ty_str
17211721
=> bcx.tcx().sess.span_bug(expr.span, "unexpected ~[T]"),
17221722
_ => deref_owned_pointer(bcx, expr, datum, content_ty),
17231723
}
@@ -1735,7 +1735,7 @@ fn deref_once<'a>(bcx: &'a Block<'a>,
17351735
ty::ty_ptr(ty::mt { ty: content_ty, .. }) |
17361736
ty::ty_rptr(_, ty::mt { ty: content_ty, .. }) => {
17371737
match ty::get(content_ty).sty {
1738-
ty::ty_vec(_, None) | ty::ty_str(None)
1738+
ty::ty_vec(_, None) | ty::ty_str
17391739
=> bcx.tcx().sess.span_bug(expr.span, "unexpected &[T]"),
17401740
_ => {
17411741
assert!(!ty::type_needs_drop(bcx.tcx(), datum.ty));

src/librustc/middle/trans/glue.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ fn get_drop_glue_type(ccx: &CrateContext, t: ty::t) -> ty::t {
8484

8585
ty::ty_uniq(typ) if !ty::type_needs_drop(tcx, typ) => {
8686
match ty::get(typ).sty {
87-
ty::ty_vec(_, None) | ty::ty_str(None) => t,
87+
ty::ty_vec(_, None) | ty::ty_str => t,
8888
_ => {
8989
let llty = sizing_type_of(ccx, typ);
9090
// 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<'
288288
trans_exchange_free(bcx, llbox)
289289
})
290290
}
291-
ty::ty_str(None) => {
291+
ty::ty_str => {
292292
with_cond(bcx, not_null, |bcx| {
293293
let unit_ty = ty::sequence_element_type(bcx.tcx(), t);
294294
let bcx = tvec::make_drop_glue_unboxed(bcx, llbox, unit_ty);

src/librustc/middle/trans/reflect.rs

+4-8
Original file line numberDiff line numberDiff line change
@@ -150,17 +150,13 @@ impl<'a, 'b> Reflector<'a, 'b> {
150150
ty::ty_float(ast::TyF64) => self.leaf("f64"),
151151
ty::ty_float(ast::TyF128) => self.leaf("f128"),
152152

153-
// Should rename to str_*/vec_*.
154-
ty::ty_str(Some(n)) => {
155-
let extra = (vec!(self.c_uint(n))).append(self.c_size_and_align(t).as_slice());
156-
self.visit("estr_fixed".to_owned(), extra.as_slice())
157-
}
153+
// Should rename to vec_*.
158154
ty::ty_vec(ref mt, Some(sz)) => {
159155
let extra = (vec!(self.c_uint(sz))).append(self.c_size_and_align(t).as_slice());
160156
let extra = extra.append(self.c_mt(mt).as_slice());
161157
self.visit("evec_fixed".to_owned(), extra.as_slice())
162158
}
163-
ty::ty_vec(..) | ty::ty_str(..) => fail!("unexpected unsized type"),
159+
ty::ty_vec(..) | ty::ty_str => fail!("unexpected unsized type"),
164160
// Should remove mt from box and uniq.
165161
ty::ty_box(typ) => {
166162
let extra = self.c_mt(&ty::mt {
@@ -176,7 +172,7 @@ impl<'a, 'b> Reflector<'a, 'b> {
176172
let extra = extra.append(self.c_mt(mt).as_slice());
177173
self.visit("evec_uniq".to_owned(), extra.as_slice())
178174
}
179-
ty::ty_str(None) => self.visit("estr_uniq".to_owned(), &[]),
175+
ty::ty_str => self.visit("estr_uniq".to_owned(), &[]),
180176
_ => {
181177
let extra = self.c_mt(&ty::mt {
182178
ty: typ,
@@ -197,7 +193,7 @@ impl<'a, 'b> Reflector<'a, 'b> {
197193
let extra = extra.append(self.c_mt(mt).as_slice());
198194
self.visit(~"evec_" + name, extra.as_slice())
199195
}
200-
ty::ty_str(None) => self.visit("estr_slice".to_owned(), &[]),
196+
ty::ty_str => self.visit("estr_slice".to_owned(), &[]),
201197
_ => {
202198
let extra = self.c_mt(mt);
203199
self.visit("rptr", extra.as_slice())

src/librustc/middle/trans/tvec.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ pub fn trans_uniq_vstore<'a>(bcx: &'a Block<'a>,
244244
let llptrval = C_cstr(ccx, (*s).clone(), false);
245245
let llptrval = PointerCast(bcx, llptrval, Type::i8p(ccx));
246246
let llsizeval = C_uint(ccx, s.get().len());
247-
let typ = ty::mk_uniq(bcx.tcx(), ty::mk_str(bcx.tcx(), None));
247+
let typ = ty::mk_uniq(bcx.tcx(), ty::mk_str(bcx.tcx()));
248248
let lldestval = rvalue_scratch_datum(bcx,
249249
typ,
250250
"");
@@ -478,13 +478,12 @@ pub fn get_base_and_len(bcx: &Block,
478478
let ccx = bcx.ccx();
479479

480480
match ty::get(vec_ty).sty {
481-
ty::ty_str(Some(n)) |
482481
ty::ty_vec(_, Some(n)) => {
483482
let base = GEPi(bcx, llval, [0u, 0u]);
484483
(base, C_uint(ccx, n))
485484
}
486485
ty::ty_rptr(_, mt) => match ty::get(mt.ty).sty {
487-
ty::ty_vec(_, None) | ty::ty_str(None) => {
486+
ty::ty_vec(_, None) | ty::ty_str => {
488487
assert!(!type_is_immediate(bcx.ccx(), vec_ty));
489488
let base = Load(bcx, GEPi(bcx, llval, [0u, abi::slice_elt_base]));
490489
let count = Load(bcx, GEPi(bcx, llval, [0u, abi::slice_elt_len]));
@@ -493,7 +492,7 @@ pub fn get_base_and_len(bcx: &Block,
493492
_ => ccx.sess().bug("unexpected type (ty_rptr) in get_base_and_len"),
494493
},
495494
ty::ty_uniq(t) => match ty::get(t).sty {
496-
ty::ty_vec(_, None) | ty::ty_str(None) => {
495+
ty::ty_vec(_, None) | ty::ty_str => {
497496
assert!(type_is_immediate(bcx.ccx(), vec_ty));
498497
let vt = vec_types(bcx, ty::sequence_element_type(bcx.tcx(), vec_ty));
499498
let body = Load(bcx, llval);

src/librustc/middle/trans/type_of.rs

+5-10
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ pub fn sizing_type_of(cx: &CrateContext, t: ty::t) -> Type {
121121
ty::ty_ptr(..) => Type::i8p(cx),
122122
ty::ty_rptr(_, mt) => {
123123
match ty::get(mt.ty).sty {
124-
ty::ty_vec(_, None) | ty::ty_str(None) => {
124+
ty::ty_vec(_, None) | ty::ty_str => {
125125
Type::struct_(cx, [Type::i8p(cx), Type::i8p(cx)], false)
126126
}
127127
_ => Type::i8p(cx),
@@ -132,7 +132,6 @@ pub fn sizing_type_of(cx: &CrateContext, t: ty::t) -> Type {
132132
ty::ty_closure(..) => Type::struct_(cx, [Type::i8p(cx), Type::i8p(cx)], false),
133133
ty::ty_trait(..) => Type::opaque_trait(cx),
134134

135-
ty::ty_str(Some(size)) => Type::array(&Type::i8(cx), size as u64),
136135
ty::ty_vec(mt, Some(size)) => {
137136
Type::array(&sizing_type_of(cx, mt.ty), size as u64)
138137
}
@@ -154,7 +153,7 @@ pub fn sizing_type_of(cx: &CrateContext, t: ty::t) -> Type {
154153
}
155154

156155
ty::ty_self(_) | ty::ty_infer(..) | ty::ty_param(..) |
157-
ty::ty_err(..) | ty::ty_vec(_, None) | ty::ty_str(None) => {
156+
ty::ty_err(..) | ty::ty_vec(_, None) | ty::ty_str => {
158157
cx.sess().bug(format!("fictitious type {:?} in sizing_type_of()",
159158
ty::get(t).sty))
160159
}
@@ -215,7 +214,7 @@ pub fn type_of(cx: &CrateContext, t: ty::t) -> Type {
215214
ty::ty_uniq(typ) => {
216215
match ty::get(typ).sty {
217216
ty::ty_vec(mt, None) => Type::vec(cx, &type_of(cx, mt.ty)).ptr_to(),
218-
ty::ty_str(None) => Type::vec(cx, &Type::i8(cx)).ptr_to(),
217+
ty::ty_str => Type::vec(cx, &Type::i8(cx)).ptr_to(),
219218
_ => type_of(cx, typ).ptr_to(),
220219
}
221220
}
@@ -227,18 +226,14 @@ pub fn type_of(cx: &CrateContext, t: ty::t) -> Type {
227226
let u_ty = Type::uint_from_ty(cx, ast::TyU);
228227
Type::struct_(cx, [p_ty, u_ty], false)
229228
}
230-
ty::ty_str(None) => {
229+
ty::ty_str => {
231230
// This means we get a nicer name in the output
232231
cx.tn.find_type("str_slice").unwrap()
233232
}
234233
_ => type_of(cx, mt.ty).ptr_to(),
235234
}
236235
}
237236

238-
ty::ty_str(Some(n)) => {
239-
Type::array(&Type::i8(cx), (n + 1u) as u64)
240-
}
241-
242237
ty::ty_vec(ref mt, Some(n)) => {
243238
Type::array(&type_of(cx, mt.ty), n as u64)
244239
}
@@ -274,7 +269,7 @@ pub fn type_of(cx: &CrateContext, t: ty::t) -> Type {
274269
}
275270

276271
ty::ty_vec(_, None) => cx.sess().bug("type_of with unsized ty_vec"),
277-
ty::ty_str(None) => cx.sess().bug("type_of with unsized ty_str"),
272+
ty::ty_str => cx.sess().bug("type_of with unsized (bare) ty_str"),
278273
ty::ty_self(..) => cx.sess().unimpl("type_of with ty_self"),
279274
ty::ty_infer(..) => cx.sess().bug("type_of with ty_infer"),
280275
ty::ty_param(..) => cx.sess().bug("type_of with ty_param"),

0 commit comments

Comments
 (0)