Skip to content

Commit 510b018

Browse files
committed
---
yaml --- r: 151173 b: refs/heads/try2 c: 5b2e477 h: refs/heads/master i: 151171: 747d536 v: v3
1 parent 5baff14 commit 510b018

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+555
-387
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 3cd6c1e008ac0696cedf6be68a4fa9d7b16550bf
8+
refs/heads/try2: 5b2e4776296a23cc6429838e8ba47c3d42513004
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/librustc/metadata/tydecode.rs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,23 @@ pub fn parse_substs_data(data: &[u8], crate_num: ast::CrateNum, pos: uint, tcx:
138138
parse_substs(&mut st, conv)
139139
}
140140

141+
fn parse_vstore(st: &mut PState, conv: conv_did) -> ty::Vstore {
142+
assert_eq!(next(st), '/');
143+
144+
let c = peek(st);
145+
if '0' <= c && c <= '9' {
146+
let n = parse_uint(st);
147+
assert_eq!(next(st), '|');
148+
return ty::VstoreFixed(n);
149+
}
150+
151+
match next(st) {
152+
'~' => ty::VstoreUniq,
153+
'&' => ty::VstoreSlice(parse_region(st, conv)),
154+
c => st.tcx.sess.bug(format!("parse_vstore(): bad input '{}'", c))
155+
}
156+
}
157+
141158
fn parse_size(st: &mut PState) -> Option<uint> {
142159
assert_eq!(next(st), '/');
143160

@@ -344,8 +361,8 @@ fn parse_ty(st: &mut PState, conv: conv_did) -> ty::t {
344361
return ty::mk_vec(st.tcx, mt, sz);
345362
}
346363
'v' => {
347-
let sz = parse_size(st);
348-
return ty::mk_str(st.tcx, sz);
364+
let v = parse_vstore(st, |x,y| conv(x,y));
365+
return ty::mk_str(st.tcx, v);
349366
}
350367
'T' => {
351368
assert_eq!(next(st), '[');

branches/try2/src/librustc/metadata/tyencode.rs

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,21 @@ fn enc_bound_region(w: &mut MemWriter, cx: &ctxt, br: ty::BoundRegion) {
177177
}
178178
}
179179

180+
pub fn enc_vstore(w: &mut MemWriter, cx: &ctxt,
181+
v: ty::Vstore,
182+
enc_mut: |&mut MemWriter|) {
183+
mywrite!(w, "/");
184+
match v {
185+
ty::VstoreFixed(u) => mywrite!(w, "{}|", u),
186+
ty::VstoreUniq => mywrite!(w, "~"),
187+
ty::VstoreSlice(r) => {
188+
mywrite!(w, "&");
189+
enc_region(w, cx, r);
190+
enc_mut(w);
191+
}
192+
}
193+
}
194+
180195
pub fn enc_trait_ref(w: &mut MemWriter, cx: &ctxt, s: &ty::TraitRef) {
181196
mywrite!(w, "{}|", (cx.ds)(s.def_id));
182197
enc_substs(w, cx, &s.substs);
@@ -260,13 +275,9 @@ fn enc_sty(w: &mut MemWriter, cx: &ctxt, st: &ty::sty) {
260275
None => mywrite!(w, "|"),
261276
}
262277
}
263-
ty::ty_str(sz) => {
278+
ty::ty_str(v) => {
264279
mywrite!(w, "v");
265-
mywrite!(w, "/");
266-
match sz {
267-
Some(n) => mywrite!(w, "{}|", n),
268-
None => mywrite!(w, "|"),
269-
}
280+
enc_vstore(w, cx, v, |_| {});
270281
}
271282
ty::ty_closure(ref f) => {
272283
mywrite!(w, "f");

branches/try2/src/librustc/middle/check_match.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,6 @@ 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),
409408
_ => check_matrix_for_wild(cx, m),
410409
},
411410
ty::ty_enum(eid, _) => {

branches/try2/src/librustc/middle/effect.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,6 @@ impl<'a> EffectCheckVisitor<'a> {
6868
debug!("effect: checking index with base type {}",
6969
ppaux::ty_to_str(self.tcx, base_type));
7070
match ty::get(base_type).sty {
71-
ty::ty_uniq(ty) | ty::ty_rptr(_, ty::mt{ty, ..}) => match ty::get(ty).sty {
72-
ty::ty_str(None) => {
73-
self.tcx.sess.span_err(e.span,
74-
"modification of string types is not allowed");
75-
}
76-
_ => {}
77-
},
7871
ty::ty_str(..) => {
7972
self.tcx.sess.span_err(e.span,
8073
"modification of string types is not allowed");

branches/try2/src/librustc/middle/lint.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -911,7 +911,7 @@ fn check_heap_type(cx: &Context, span: Span, ty: ty::t) {
911911
ty::ty_box(_) => {
912912
n_box += 1;
913913
}
914-
ty::ty_uniq(_) |
914+
ty::ty_uniq(_) | ty::ty_str(ty::VstoreUniq) |
915915
ty::ty_trait(~ty::TyTrait { store: ty::UniqTraitStore, .. }) |
916916
ty::ty_closure(~ty::ClosureTy { store: ty::UniqTraitStore, .. }) => {
917917
n_uniq += 1;

branches/try2/src/librustc/middle/mem_categorization.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ pub fn opt_deref_kind(t: ty::t) -> Option<deref_kind> {
174174
match ty::get(t).sty {
175175
ty::ty_uniq(_) |
176176
ty::ty_trait(~ty::TyTrait { store: ty::UniqTraitStore, .. }) |
177+
ty::ty_str(ty::VstoreUniq) |
177178
ty::ty_closure(~ty::ClosureTy {store: ty::UniqTraitStore, ..}) => {
178179
Some(deref_ptr(OwnedPtr))
179180
}
@@ -187,6 +188,7 @@ pub fn opt_deref_kind(t: ty::t) -> Option<deref_kind> {
187188
Some(deref_ptr(BorrowedPtr(kind, r)))
188189
}
189190

191+
ty::ty_str(ty::VstoreSlice(r)) |
190192
ty::ty_closure(~ty::ClosureTy {store: ty::RegionTraitStore(r, _), ..}) => {
191193
Some(deref_ptr(BorrowedPtr(ty::ImmBorrow, r)))
192194
}
@@ -205,7 +207,7 @@ pub fn opt_deref_kind(t: ty::t) -> Option<deref_kind> {
205207
}
206208

207209
ty::ty_vec(_, Some(_)) |
208-
ty::ty_str(Some(_)) => {
210+
ty::ty_str(ty::VstoreFixed(_)) => {
209211
Some(deref_interior(InteriorElement(element_kind(t))))
210212
}
211213

@@ -1304,7 +1306,6 @@ fn element_kind(t: ty::t) -> ElementKind {
13041306
ty::ty_rptr(_, ty::mt{ty:ty, ..}) |
13051307
ty::ty_uniq(ty) => match ty::get(ty).sty {
13061308
ty::ty_vec(_, None) => VecElement,
1307-
ty::ty_str(None) => StrElement,
13081309
_ => OtherElement
13091310
},
13101311
ty::ty_vec(..) => VecElement,

branches/try2/src/librustc/middle/trans/_match.rs

Lines changed: 28 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1293,51 +1293,40 @@ fn compare_values<'a>(
12931293
rhs: ValueRef,
12941294
rhs_t: ty::t)
12951295
-> Result<'a> {
1296-
fn compare_str<'a>(cx: &'a Block<'a>,
1297-
lhs: ValueRef,
1298-
rhs: ValueRef,
1299-
rhs_t: ty::t)
1300-
-> Result<'a> {
1301-
let did = langcall(cx, None,
1302-
format!("comparison of `{}`", cx.ty_to_str(rhs_t)),
1303-
StrEqFnLangItem);
1304-
let result = callee::trans_lang_call(cx, did, [lhs, rhs], None);
1305-
Result {
1306-
bcx: result.bcx,
1307-
val: bool_to_i1(result.bcx, result.val)
1308-
}
1309-
}
1310-
13111296
let _icx = push_ctxt("compare_values");
13121297
if ty::type_is_scalar(rhs_t) {
1313-
let rs = compare_scalar_types(cx, lhs, rhs, rhs_t, ast::BiEq);
1314-
return rslt(rs.bcx, rs.val);
1298+
let rs = compare_scalar_types(cx, lhs, rhs, rhs_t, ast::BiEq);
1299+
return rslt(rs.bcx, rs.val);
13151300
}
13161301

13171302
match ty::get(rhs_t).sty {
1318-
ty::ty_uniq(t) => match ty::get(t).sty {
1319-
ty::ty_str(None) => {
1320-
let scratch_lhs = alloca(cx, val_ty(lhs), "__lhs");
1321-
Store(cx, lhs, scratch_lhs);
1322-
let scratch_rhs = alloca(cx, val_ty(rhs), "__rhs");
1323-
Store(cx, rhs, scratch_rhs);
1324-
let did = langcall(cx, None,
1325-
format!("comparison of `{}`", cx.ty_to_str(rhs_t)),
1326-
UniqStrEqFnLangItem);
1327-
let result = callee::trans_lang_call(cx, did, [scratch_lhs, scratch_rhs], None);
1328-
Result {
1329-
bcx: result.bcx,
1330-
val: bool_to_i1(result.bcx, result.val)
1331-
}
1303+
ty::ty_str(ty::VstoreUniq) => {
1304+
let scratch_lhs = alloca(cx, val_ty(lhs), "__lhs");
1305+
Store(cx, lhs, scratch_lhs);
1306+
let scratch_rhs = alloca(cx, val_ty(rhs), "__rhs");
1307+
Store(cx, rhs, scratch_rhs);
1308+
let did = langcall(cx, None,
1309+
format!("comparison of `{}`", cx.ty_to_str(rhs_t)),
1310+
UniqStrEqFnLangItem);
1311+
let result = callee::trans_lang_call(cx, did, [scratch_lhs, scratch_rhs], None);
1312+
Result {
1313+
bcx: result.bcx,
1314+
val: bool_to_i1(result.bcx, result.val)
1315+
}
1316+
}
1317+
ty::ty_str(_) => {
1318+
let did = langcall(cx, None,
1319+
format!("comparison of `{}`", cx.ty_to_str(rhs_t)),
1320+
StrEqFnLangItem);
1321+
let result = callee::trans_lang_call(cx, did, [lhs, rhs], None);
1322+
Result {
1323+
bcx: result.bcx,
1324+
val: bool_to_i1(result.bcx, result.val)
13321325
}
1333-
_ => cx.sess().bug("only scalars and strings supported in compare_values"),
1334-
},
1335-
ty::ty_rptr(_, mt) => match ty::get(mt.ty).sty {
1336-
ty::ty_str(None) => compare_str(cx, lhs, rhs, rhs_t),
1337-
_ => cx.sess().bug("only scalars and strings supported in compare_values"),
1338-
},
1339-
ty::ty_str(Some(_)) => compare_str(cx, lhs, rhs, rhs_t),
1340-
_ => cx.sess().bug("only scalars and strings supported in compare_values"),
1326+
}
1327+
_ => {
1328+
cx.sess().bug("only scalars and strings supported in compare_values");
1329+
}
13411330
}
13421331
}
13431332

branches/try2/src/librustc/middle/trans/adt.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,10 +270,11 @@ 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) => false,
274274
_ => true,
275275
},
276276
ty::ty_uniq(..) | ty::ty_box(..) |
277+
ty::ty_str(ty::VstoreUniq) |
277278
ty::ty_bare_fn(..) => true,
278279
// Is that everything? Would closures or slices qualify?
279280
_ => false

branches/try2/src/librustc/middle/trans/base.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,8 @@ fn decl_fn(llmod: ModuleRef, name: &str, cc: lib::llvm::CallConv,
188188
// `~` pointer return values never alias because ownership is transferred
189189
// FIXME #6750 ~Trait cannot be directly marked as
190190
// noalias because the actual object pointer is nested.
191-
ty::ty_uniq(..) // | ty::ty_trait(_, _, ty::UniqTraitStore, _, _)
192-
=> {
191+
ty::ty_uniq(..) | // ty::ty_trait(_, _, ty::UniqTraitStore, _, _) |
192+
ty::ty_str(ty::VstoreUniq) => {
193193
unsafe {
194194
llvm::LLVMAddReturnAttribute(llfn, lib::llvm::NoAliasAttribute as c_uint);
195195
}
@@ -261,6 +261,7 @@ pub fn decl_rust_fn(ccx: &CrateContext, has_env: bool,
261261
// FIXME #6750 ~Trait cannot be directly marked as
262262
// noalias because the actual object pointer is nested.
263263
ty::ty_uniq(..) | // ty::ty_trait(_, _, ty::UniqTraitStore, _, _) |
264+
ty::ty_str(ty::VstoreUniq) |
264265
ty::ty_closure(~ty::ClosureTy {store: ty::UniqTraitStore, ..}) => {
265266
unsafe {
266267
llvm::LLVMAddAttribute(llarg, lib::llvm::NoAliasAttribute as c_uint);
@@ -664,7 +665,7 @@ pub fn iter_structural_ty<'r,
664665
}
665666
})
666667
}
667-
ty::ty_str(Some(n)) => {
668+
ty::ty_str(ty::VstoreFixed(n)) => {
668669
let unit_ty = ty::sequence_element_type(cx.tcx(), t);
669670
let (base, len) = tvec::get_fixed_base_and_byte_len(cx, av, unit_ty, n);
670671
cx = tvec::iter_vec_raw(cx, base, unit_ty, len, f);

branches/try2/src/librustc/middle/trans/callee.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -659,10 +659,9 @@ pub fn trans_call_inner<'a>(
659659
match ty::get(ret_ty).sty {
660660
// `~` pointer return values never alias because ownership
661661
// is transferred
662-
ty::ty_uniq(ty) => match ty::get(ty).sty {
663-
ty::ty_str(None) => {}
664-
_ => attrs.push((0, NoAliasAttribute)),
665-
},
662+
ty::ty_uniq(..) => {
663+
attrs.push((0, NoAliasAttribute));
664+
}
666665
_ => {}
667666
}
668667

branches/try2/src/librustc/middle/trans/consts.rs

Lines changed: 7 additions & 13 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) => cx.sess().bug("unexpected slice"),
145145
_ => const_deref_ptr(cx, v),
146146
}
147147
}
@@ -432,9 +432,13 @@ fn const_expr_unadjusted(cx: &CrateContext, e: &ast::Expr,
432432
"index is not an integer-constant expression")
433433
};
434434
let (arr, len) = match ty::get(bt).sty {
435+
ty::ty_str(ty::VstoreSlice(..)) => {
436+
let e1 = const_get_elt(cx, bv, [0]);
437+
(const_deref_ptr(cx, e1), const_get_elt(cx, bv, [1]))
438+
},
435439
ty::ty_vec(_, Some(u)) => (bv, C_uint(cx, u)),
436440
ty::ty_rptr(_, mt) => match ty::get(mt.ty).sty {
437-
ty::ty_vec(_, None) | ty::ty_str(None) => {
441+
ty::ty_vec(_, None) => {
438442
let e1 = const_get_elt(cx, bv, [0]);
439443
(const_deref_ptr(cx, e1), const_get_elt(cx, bv, [1]))
440444
},
@@ -447,17 +451,7 @@ fn const_expr_unadjusted(cx: &CrateContext, e: &ast::Expr,
447451

448452
let len = llvm::LLVMConstIntGetZExtValue(len) as u64;
449453
let len = match ty::get(bt).sty {
450-
ty::ty_uniq(ty) | ty::ty_rptr(_, ty::mt{ty, ..}) => match ty::get(ty).sty {
451-
ty::ty_str(None) => {
452-
assert!(len > 0);
453-
len - 1
454-
}
455-
_ => len
456-
},
457-
ty::ty_str(Some(_)) => {
458-
assert!(len > 0);
459-
len - 1
460-
},
454+
ty::ty_str(..) => {assert!(len > 0); len - 1},
461455
_ => len
462456
};
463457
if iv >= len {

0 commit comments

Comments
 (0)