Skip to content

Commit 8fdf1e2

Browse files
committed
auto merge of #13834 : nick29581/rust/str_fix, r=luqmana
2 parents a72a6ec + f3c3389 commit 8fdf1e2

26 files changed

+72
-131
lines changed

src/librustc/metadata/tydecode.rs

Lines changed: 1 addition & 2 deletions
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

Lines changed: 1 addition & 6 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 2 additions & 4 deletions
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

Lines changed: 2 additions & 3 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 0 additions & 5 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 3 additions & 7 deletions
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 {

0 commit comments

Comments
 (0)