rustc: Remove the vstore handling of @str and @[].
This commit is contained in:
parent
e39cd20a43
commit
ec4b456b26
20 changed files with 47 additions and 129 deletions
|
@ -156,7 +156,6 @@ fn parse_vstore(st: &mut PState, conv: conv_did) -> ty::vstore {
|
||||||
|
|
||||||
match next(st) {
|
match next(st) {
|
||||||
'~' => ty::vstore_uniq,
|
'~' => ty::vstore_uniq,
|
||||||
'@' => ty::vstore_box,
|
|
||||||
'&' => ty::vstore_slice(parse_region(st, conv)),
|
'&' => ty::vstore_slice(parse_region(st, conv)),
|
||||||
c => st.tcx.sess.bug(format!("parse_vstore(): bad input '{}'", c))
|
c => st.tcx.sess.bug(format!("parse_vstore(): bad input '{}'", c))
|
||||||
}
|
}
|
||||||
|
|
|
@ -219,7 +219,6 @@ pub fn enc_vstore(w: &mut MemWriter, cx: @ctxt, v: ty::vstore) {
|
||||||
match v {
|
match v {
|
||||||
ty::vstore_fixed(u) => mywrite!(w, "{}|", u),
|
ty::vstore_fixed(u) => mywrite!(w, "{}|", u),
|
||||||
ty::vstore_uniq => mywrite!(w, "~"),
|
ty::vstore_uniq => mywrite!(w, "~"),
|
||||||
ty::vstore_box => mywrite!(w, "@"),
|
|
||||||
ty::vstore_slice(r) => {
|
ty::vstore_slice(r) => {
|
||||||
mywrite!(w, "&");
|
mywrite!(w, "&");
|
||||||
enc_region(w, cx, r);
|
enc_region(w, cx, r);
|
||||||
|
|
|
@ -888,7 +888,6 @@ fn check_heap_type(cx: &Context, span: Span, ty: ty::t) {
|
||||||
ty::fold_ty(cx.tcx, ty, |t| {
|
ty::fold_ty(cx.tcx, ty, |t| {
|
||||||
match ty::get(t).sty {
|
match ty::get(t).sty {
|
||||||
ty::ty_box(_) |
|
ty::ty_box(_) |
|
||||||
ty::ty_vec(_, ty::vstore_box) |
|
|
||||||
ty::ty_trait(_, _, ty::BoxTraitStore, _, _) => {
|
ty::ty_trait(_, _, ty::BoxTraitStore, _, _) => {
|
||||||
n_box += 1;
|
n_box += 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -178,7 +178,6 @@ pub fn opt_deref_kind(t: ty::t) -> Option<deref_kind> {
|
||||||
}
|
}
|
||||||
|
|
||||||
ty::ty_box(_) |
|
ty::ty_box(_) |
|
||||||
ty::ty_vec(_, ty::vstore_box) |
|
|
||||||
ty::ty_trait(_, _, ty::BoxTraitStore, _, _) => {
|
ty::ty_trait(_, _, ty::BoxTraitStore, _, _) => {
|
||||||
Some(deref_ptr(gc_ptr))
|
Some(deref_ptr(gc_ptr))
|
||||||
}
|
}
|
||||||
|
|
|
@ -768,7 +768,6 @@ pub fn mono_data_classify(t: ty::t) -> MonoDataClass {
|
||||||
ty::ty_float(_) => MonoFloat,
|
ty::ty_float(_) => MonoFloat,
|
||||||
ty::ty_rptr(..) | ty::ty_uniq(..) | ty::ty_box(..) |
|
ty::ty_rptr(..) | ty::ty_uniq(..) | ty::ty_box(..) |
|
||||||
ty::ty_str(ty::vstore_uniq) | ty::ty_vec(_, ty::vstore_uniq) |
|
ty::ty_str(ty::vstore_uniq) | ty::ty_vec(_, ty::vstore_uniq) |
|
||||||
ty::ty_str(ty::vstore_box) | ty::ty_vec(_, ty::vstore_box) |
|
|
||||||
ty::ty_bare_fn(..) => MonoNonNull,
|
ty::ty_bare_fn(..) => MonoNonNull,
|
||||||
// Is that everything? Would closures or slices qualify?
|
// Is that everything? Would closures or slices qualify?
|
||||||
_ => MonoBits
|
_ => MonoBits
|
||||||
|
|
|
@ -1896,23 +1896,6 @@ fn vec_metadata(cx: &CrateContext,
|
||||||
span);
|
span);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn boxed_vec_metadata(cx: &CrateContext,
|
|
||||||
element_type: ty::t,
|
|
||||||
span: Span)
|
|
||||||
-> DICompositeType {
|
|
||||||
let element_llvm_type = type_of::type_of(cx, element_type);
|
|
||||||
let vec_llvm_type = Type::vec(cx.sess.targ_cfg.arch, &element_llvm_type);
|
|
||||||
let vec_type_name: &str = format!("[{}]", ppaux::ty_to_str(cx.tcx, element_type));
|
|
||||||
let vec_metadata = vec_metadata(cx, element_type, span);
|
|
||||||
|
|
||||||
return boxed_type_metadata(
|
|
||||||
cx,
|
|
||||||
Some(vec_type_name),
|
|
||||||
vec_llvm_type,
|
|
||||||
vec_metadata,
|
|
||||||
span);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn vec_slice_metadata(cx: &CrateContext,
|
fn vec_slice_metadata(cx: &CrateContext,
|
||||||
vec_type: ty::t,
|
vec_type: ty::t,
|
||||||
element_type: ty::t,
|
element_type: ty::t,
|
||||||
|
@ -2093,9 +2076,6 @@ fn type_metadata(cx: &CrateContext,
|
||||||
let vec_metadata = vec_metadata(cx, i8_t, usage_site_span);
|
let vec_metadata = vec_metadata(cx, i8_t, usage_site_span);
|
||||||
pointer_type_metadata(cx, t, vec_metadata)
|
pointer_type_metadata(cx, t, vec_metadata)
|
||||||
}
|
}
|
||||||
ty::vstore_box => {
|
|
||||||
fail!("unexpected managed string")
|
|
||||||
}
|
|
||||||
ty::vstore_slice(_region) => {
|
ty::vstore_slice(_region) => {
|
||||||
vec_slice_metadata(cx, t, i8_t, usage_site_span)
|
vec_slice_metadata(cx, t, i8_t, usage_site_span)
|
||||||
}
|
}
|
||||||
|
@ -2116,10 +2096,6 @@ fn type_metadata(cx: &CrateContext,
|
||||||
let vec_metadata = vec_metadata(cx, mt.ty, usage_site_span);
|
let vec_metadata = vec_metadata(cx, mt.ty, usage_site_span);
|
||||||
pointer_type_metadata(cx, t, vec_metadata)
|
pointer_type_metadata(cx, t, vec_metadata)
|
||||||
}
|
}
|
||||||
ty::vstore_box => {
|
|
||||||
let boxed_vec_metadata = boxed_vec_metadata(cx, mt.ty, usage_site_span);
|
|
||||||
pointer_type_metadata(cx, t, boxed_vec_metadata)
|
|
||||||
}
|
|
||||||
ty::vstore_slice(_) => {
|
ty::vstore_slice(_) => {
|
||||||
vec_slice_metadata(cx, t, mt.ty, usage_site_span)
|
vec_slice_metadata(cx, t, mt.ty, usage_site_span)
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,10 +64,7 @@ pub fn take_ty<'a>(bcx: &'a Block<'a>, v: ValueRef, t: ty::t)
|
||||||
// NB: v is an *alias* of type t here, not a direct value.
|
// NB: v is an *alias* of type t here, not a direct value.
|
||||||
let _icx = push_ctxt("take_ty");
|
let _icx = push_ctxt("take_ty");
|
||||||
match ty::get(t).sty {
|
match ty::get(t).sty {
|
||||||
ty::ty_box(_) |
|
ty::ty_box(_) => incr_refcnt_of_boxed(bcx, v),
|
||||||
ty::ty_vec(_, ty::vstore_box) | ty::ty_str(ty::vstore_box) => {
|
|
||||||
incr_refcnt_of_boxed(bcx, v)
|
|
||||||
}
|
|
||||||
ty::ty_trait(_, _, ty::BoxTraitStore, _, _) => {
|
ty::ty_trait(_, _, ty::BoxTraitStore, _, _) => {
|
||||||
incr_refcnt_of_boxed(bcx, GEPi(bcx, v, [0u, abi::trt_field_box]))
|
incr_refcnt_of_boxed(bcx, GEPi(bcx, v, [0u, abi::trt_field_box]))
|
||||||
}
|
}
|
||||||
|
@ -113,10 +110,6 @@ fn simplified_glue_type(tcx: ty::ctxt, field: uint, t: ty::t) -> ty::t {
|
||||||
if !ty::type_needs_drop(tcx, typ) =>
|
if !ty::type_needs_drop(tcx, typ) =>
|
||||||
return ty::mk_box(tcx, ty::mk_nil()),
|
return ty::mk_box(tcx, ty::mk_nil()),
|
||||||
|
|
||||||
ty::ty_vec(mt, ty::vstore_box)
|
|
||||||
if !ty::type_needs_drop(tcx, mt.ty) =>
|
|
||||||
return ty::mk_box(tcx, ty::mk_nil()),
|
|
||||||
|
|
||||||
ty::ty_uniq(typ)
|
ty::ty_uniq(typ)
|
||||||
if !ty::type_needs_drop(tcx, typ) =>
|
if !ty::type_needs_drop(tcx, typ) =>
|
||||||
return ty::mk_uniq(tcx, ty::mk_nil()),
|
return ty::mk_uniq(tcx, ty::mk_nil()),
|
||||||
|
@ -326,11 +319,6 @@ fn make_drop_glue<'a>(bcx: &'a Block<'a>, v0: ValueRef, t: ty::t) -> &'a Block<'
|
||||||
ty::ty_box(body_ty) => {
|
ty::ty_box(body_ty) => {
|
||||||
decr_refcnt_maybe_free(bcx, v0, Some(body_ty))
|
decr_refcnt_maybe_free(bcx, v0, Some(body_ty))
|
||||||
}
|
}
|
||||||
ty::ty_str(ty::vstore_box) | ty::ty_vec(_, ty::vstore_box) => {
|
|
||||||
let unit_ty = ty::sequence_element_type(ccx.tcx, t);
|
|
||||||
let unboxed_vec_ty = ty::mk_mut_unboxed_vec(ccx.tcx, unit_ty);
|
|
||||||
decr_refcnt_maybe_free(bcx, v0, Some(unboxed_vec_ty))
|
|
||||||
}
|
|
||||||
ty::ty_uniq(content_ty) => {
|
ty::ty_uniq(content_ty) => {
|
||||||
let llbox = Load(bcx, v0);
|
let llbox = Load(bcx, v0);
|
||||||
let not_null = IsNotNull(bcx, llbox);
|
let not_null = IsNotNull(bcx, llbox);
|
||||||
|
|
|
@ -140,7 +140,6 @@ impl<'a> Reflector<'a> {
|
||||||
}
|
}
|
||||||
ty::vstore_slice(_) => (~"slice", ~[]),
|
ty::vstore_slice(_) => (~"slice", ~[]),
|
||||||
ty::vstore_uniq => (~"uniq", ~[]),
|
ty::vstore_uniq => (~"uniq", ~[]),
|
||||||
ty::vstore_box => (~"box", ~[])
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,9 +44,6 @@ pub fn expand_boxed_vec_ty(tcx: ty::ctxt, t: ty::t) -> ty::t {
|
||||||
ty::ty_str(ty::vstore_uniq) | ty::ty_vec(_, ty::vstore_uniq) => {
|
ty::ty_str(ty::vstore_uniq) | ty::ty_vec(_, ty::vstore_uniq) => {
|
||||||
ty::mk_uniq(tcx, unboxed_vec_ty)
|
ty::mk_uniq(tcx, unboxed_vec_ty)
|
||||||
}
|
}
|
||||||
ty::ty_str(ty::vstore_box) | ty::ty_vec(_, ty::vstore_box) => {
|
|
||||||
ty::mk_box(tcx, unboxed_vec_ty)
|
|
||||||
}
|
|
||||||
_ => tcx.sess.bug("non boxed-vec type \
|
_ => tcx.sess.bug("non boxed-vec type \
|
||||||
in tvec::expand_boxed_vec_ty")
|
in tvec::expand_boxed_vec_ty")
|
||||||
}
|
}
|
||||||
|
@ -65,21 +62,6 @@ pub fn get_alloc(bcx: &Block, vptr: ValueRef) -> ValueRef {
|
||||||
Load(bcx, GEPi(bcx, vptr, [0u, abi::vec_elt_alloc]))
|
Load(bcx, GEPi(bcx, vptr, [0u, abi::vec_elt_alloc]))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_bodyptr(bcx: &Block, vptr: ValueRef, t: ty::t) -> ValueRef {
|
|
||||||
let vt = vec_types(bcx, t);
|
|
||||||
|
|
||||||
let managed = match ty::get(vt.vec_ty).sty {
|
|
||||||
ty::ty_str(ty::vstore_box) | ty::ty_vec(_, ty::vstore_box) => true,
|
|
||||||
_ => false
|
|
||||||
};
|
|
||||||
|
|
||||||
if managed {
|
|
||||||
GEPi(bcx, vptr, [0u, abi::box_field_body])
|
|
||||||
} else {
|
|
||||||
vptr
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn get_dataptr(bcx: &Block, vptr: ValueRef) -> ValueRef {
|
pub fn get_dataptr(bcx: &Block, vptr: ValueRef) -> ValueRef {
|
||||||
let _icx = push_ctxt("tvec::get_dataptr");
|
let _icx = push_ctxt("tvec::get_dataptr");
|
||||||
GEPi(bcx, vptr, [0u, abi::vec_elt_elems, 0u])
|
GEPi(bcx, vptr, [0u, abi::vec_elt_elems, 0u])
|
||||||
|
@ -381,7 +363,7 @@ pub fn trans_uniq_or_managed_vstore<'a>(bcx: &'a Block<'a>,
|
||||||
let temp_scope = fcx.push_custom_cleanup_scope();
|
let temp_scope = fcx.push_custom_cleanup_scope();
|
||||||
fcx.schedule_free_value(cleanup::CustomScope(temp_scope), val, heap);
|
fcx.schedule_free_value(cleanup::CustomScope(temp_scope), val, heap);
|
||||||
|
|
||||||
let dataptr = get_dataptr(bcx, get_bodyptr(bcx, val, vt.vec_ty));
|
let dataptr = get_dataptr(bcx, val);
|
||||||
|
|
||||||
debug!("alloc_vec() returned val={}, dataptr={}",
|
debug!("alloc_vec() returned val={}, dataptr={}",
|
||||||
bcx.val_to_str(val), bcx.val_to_str(dataptr));
|
bcx.val_to_str(val), bcx.val_to_str(dataptr));
|
||||||
|
@ -570,10 +552,9 @@ pub fn get_base_and_byte_len(bcx: &Block,
|
||||||
let len = Mul(bcx, count, vt.llunit_size);
|
let len = Mul(bcx, count, vt.llunit_size);
|
||||||
(base, len)
|
(base, len)
|
||||||
}
|
}
|
||||||
ty::vstore_uniq | ty::vstore_box => {
|
ty::vstore_uniq => {
|
||||||
assert!(type_is_immediate(bcx.ccx(), vt.vec_ty));
|
assert!(type_is_immediate(bcx.ccx(), vt.vec_ty));
|
||||||
let llval = Load(bcx, llval);
|
let body = Load(bcx, llval);
|
||||||
let body = get_bodyptr(bcx, llval, vec_ty);
|
|
||||||
(get_dataptr(bcx, body), get_fill(bcx, body))
|
(get_dataptr(bcx, body), get_fill(bcx, body))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -610,10 +591,9 @@ pub fn get_base_and_len(bcx: &Block,
|
||||||
let count = Load(bcx, GEPi(bcx, llval, [0u, abi::slice_elt_len]));
|
let count = Load(bcx, GEPi(bcx, llval, [0u, abi::slice_elt_len]));
|
||||||
(base, count)
|
(base, count)
|
||||||
}
|
}
|
||||||
ty::vstore_uniq | ty::vstore_box => {
|
ty::vstore_uniq => {
|
||||||
assert!(type_is_immediate(bcx.ccx(), vt.vec_ty));
|
assert!(type_is_immediate(bcx.ccx(), vt.vec_ty));
|
||||||
let llval = Load(bcx, llval);
|
let body = Load(bcx, llval);
|
||||||
let body = get_bodyptr(bcx, llval, vec_ty);
|
|
||||||
(get_dataptr(bcx, body), UDiv(bcx, get_fill(bcx, body), vt.llunit_size))
|
(get_dataptr(bcx, body), UDiv(bcx, get_fill(bcx, body), vt.llunit_size))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -730,7 +710,7 @@ pub fn iter_vec_uniq<'r,
|
||||||
f: iter_vec_block<'r,'b>)
|
f: iter_vec_block<'r,'b>)
|
||||||
-> &'b Block<'b> {
|
-> &'b Block<'b> {
|
||||||
let _icx = push_ctxt("tvec::iter_vec_uniq");
|
let _icx = push_ctxt("tvec::iter_vec_uniq");
|
||||||
let data_ptr = get_dataptr(bcx, get_bodyptr(bcx, vptr, vec_ty));
|
let data_ptr = get_dataptr(bcx, vptr);
|
||||||
iter_vec_raw(bcx, data_ptr, vec_ty, fill, f)
|
iter_vec_raw(bcx, data_ptr, vec_ty, fill, f)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -115,9 +115,7 @@ pub fn sizing_type_of(cx: &CrateContext, t: ty::t) -> Type {
|
||||||
ty::ty_float(t) => Type::float_from_ty(t),
|
ty::ty_float(t) => Type::float_from_ty(t),
|
||||||
|
|
||||||
ty::ty_str(ty::vstore_uniq) |
|
ty::ty_str(ty::vstore_uniq) |
|
||||||
ty::ty_str(ty::vstore_box) |
|
|
||||||
ty::ty_vec(_, ty::vstore_uniq) |
|
ty::ty_vec(_, ty::vstore_uniq) |
|
||||||
ty::ty_vec(_, ty::vstore_box) |
|
|
||||||
ty::ty_box(..) |
|
ty::ty_box(..) |
|
||||||
ty::ty_uniq(..) |
|
ty::ty_uniq(..) |
|
||||||
ty::ty_ptr(..) |
|
ty::ty_ptr(..) |
|
||||||
|
@ -221,13 +219,6 @@ pub fn type_of(cx: &CrateContext, t: ty::t) -> Type {
|
||||||
let name = llvm_type_name(cx, an_enum, did, substs.tps);
|
let name = llvm_type_name(cx, an_enum, did, substs.tps);
|
||||||
adt::incomplete_type_of(cx, repr, name)
|
adt::incomplete_type_of(cx, repr, name)
|
||||||
}
|
}
|
||||||
ty::ty_str(ty::vstore_box) => {
|
|
||||||
fail!("unexpected managed string")
|
|
||||||
}
|
|
||||||
ty::ty_vec(ref mt, ty::vstore_box) => {
|
|
||||||
let e_ty = type_of(cx, mt.ty);
|
|
||||||
Type::at_box(cx, Type::vec(cx.sess.targ_cfg.arch, &e_ty)).ptr_to()
|
|
||||||
}
|
|
||||||
ty::ty_box(typ) => {
|
ty::ty_box(typ) => {
|
||||||
Type::at_box(cx, type_of(cx, typ)).ptr_to()
|
Type::at_box(cx, type_of(cx, typ)).ptr_to()
|
||||||
}
|
}
|
||||||
|
|
|
@ -130,7 +130,6 @@ pub struct mt {
|
||||||
pub enum vstore {
|
pub enum vstore {
|
||||||
vstore_fixed(uint),
|
vstore_fixed(uint),
|
||||||
vstore_uniq,
|
vstore_uniq,
|
||||||
vstore_box,
|
|
||||||
vstore_slice(Region)
|
vstore_slice(Region)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1558,7 +1557,7 @@ pub fn type_is_box(ty: t) -> bool {
|
||||||
|
|
||||||
pub fn type_is_boxed(ty: t) -> bool {
|
pub fn type_is_boxed(ty: t) -> bool {
|
||||||
match get(ty).sty {
|
match get(ty).sty {
|
||||||
ty_box(_) | ty_vec(_, vstore_box) | ty_str(vstore_box) => true,
|
ty_box(_) => true,
|
||||||
_ => false
|
_ => false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1682,10 +1681,7 @@ fn type_needs_unwind_cleanup_(cx: ctxt, ty: t,
|
||||||
}
|
}
|
||||||
ty_uniq(_) |
|
ty_uniq(_) |
|
||||||
ty_str(vstore_uniq) |
|
ty_str(vstore_uniq) |
|
||||||
ty_str(vstore_box) |
|
ty_vec(_, vstore_uniq) => {
|
||||||
ty_vec(_, vstore_uniq) |
|
|
||||||
ty_vec(_, vstore_box)
|
|
||||||
=> {
|
|
||||||
// Once we're inside a box, the annihilator will find
|
// Once we're inside a box, the annihilator will find
|
||||||
// it and destroy it.
|
// it and destroy it.
|
||||||
if !encountered_box {
|
if !encountered_box {
|
||||||
|
@ -2028,10 +2024,6 @@ pub fn type_contents(cx: ctxt, ty: t) -> TypeContents {
|
||||||
tc_mt(cx, mt, cache).owned_pointer()
|
tc_mt(cx, mt, cache).owned_pointer()
|
||||||
}
|
}
|
||||||
|
|
||||||
ty_vec(mt, vstore_box) => {
|
|
||||||
tc_mt(cx, mt, cache).managed_pointer()
|
|
||||||
}
|
|
||||||
|
|
||||||
ty_vec(ref mt, vstore_slice(r)) => {
|
ty_vec(ref mt, vstore_slice(r)) => {
|
||||||
tc_ty(cx, mt.ty, cache).reference(
|
tc_ty(cx, mt.ty, cache).reference(
|
||||||
borrowed_contents(r, mt.mutbl))
|
borrowed_contents(r, mt.mutbl))
|
||||||
|
@ -2041,10 +2033,6 @@ pub fn type_contents(cx: ctxt, ty: t) -> TypeContents {
|
||||||
tc_mt(cx, mt, cache)
|
tc_mt(cx, mt, cache)
|
||||||
}
|
}
|
||||||
|
|
||||||
ty_str(vstore_box) => {
|
|
||||||
TC::Managed
|
|
||||||
}
|
|
||||||
|
|
||||||
ty_str(vstore_slice(r)) => {
|
ty_str(vstore_slice(r)) => {
|
||||||
borrowed_contents(r, ast::MutImmutable)
|
borrowed_contents(r, ast::MutImmutable)
|
||||||
}
|
}
|
||||||
|
@ -2530,8 +2518,8 @@ pub fn type_is_pod(cx: ctxt, ty: t) -> bool {
|
||||||
ty_type | ty_ptr(_) | ty_bare_fn(_) => result = true,
|
ty_type | ty_ptr(_) | ty_bare_fn(_) => result = true,
|
||||||
// Boxed types
|
// Boxed types
|
||||||
ty_box(_) | ty_uniq(_) | ty_closure(_) |
|
ty_box(_) | ty_uniq(_) | ty_closure(_) |
|
||||||
ty_str(vstore_uniq) | ty_str(vstore_box) |
|
ty_str(vstore_uniq) |
|
||||||
ty_vec(_, vstore_uniq) | ty_vec(_, vstore_box) |
|
ty_vec(_, vstore_uniq) |
|
||||||
ty_trait(_, _, _, _, _) | ty_rptr(_,_) => result = false,
|
ty_trait(_, _, _, _, _) | ty_rptr(_,_) => result = false,
|
||||||
// Structural types
|
// Structural types
|
||||||
ty_enum(did, ref substs) => {
|
ty_enum(did, ref substs) => {
|
||||||
|
@ -4426,7 +4414,7 @@ pub fn normalize_ty(cx: ctxt, t: t) -> t {
|
||||||
|
|
||||||
fn fold_vstore(&mut self, vstore: vstore) -> vstore {
|
fn fold_vstore(&mut self, vstore: vstore) -> vstore {
|
||||||
match vstore {
|
match vstore {
|
||||||
vstore_fixed(..) | vstore_uniq | vstore_box => vstore,
|
vstore_fixed(..) | vstore_uniq => vstore,
|
||||||
vstore_slice(_) => vstore_slice(ReStatic)
|
vstore_slice(_) => vstore_slice(ReStatic)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4863,7 +4851,6 @@ pub fn hash_crate_independent(tcx: ctxt, t: t, local_hash: ~str) -> u64 {
|
||||||
match v {
|
match v {
|
||||||
vstore_fixed(_) => hash.input([0]),
|
vstore_fixed(_) => hash.input([0]),
|
||||||
vstore_uniq => hash.input([1]),
|
vstore_uniq => hash.input([1]),
|
||||||
vstore_box => hash.input([2]),
|
|
||||||
vstore_slice(r) => {
|
vstore_slice(r) => {
|
||||||
hash.input([3]);
|
hash.input([3]);
|
||||||
region(hash, r);
|
region(hash, r);
|
||||||
|
|
|
@ -202,7 +202,6 @@ pub fn super_fold_vstore<T:TypeFolder>(this: &mut T,
|
||||||
match vstore {
|
match vstore {
|
||||||
ty::vstore_fixed(i) => ty::vstore_fixed(i),
|
ty::vstore_fixed(i) => ty::vstore_fixed(i),
|
||||||
ty::vstore_uniq => ty::vstore_uniq,
|
ty::vstore_uniq => ty::vstore_uniq,
|
||||||
ty::vstore_box => ty::vstore_box,
|
|
||||||
ty::vstore_slice(r) => ty::vstore_slice(this.fold_region(r)),
|
ty::vstore_slice(r) => ty::vstore_slice(this.fold_region(r)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -384,6 +384,23 @@ pub fn ast_ty_to_ty<AC:AstConv, RS:RegionScope>(
|
||||||
ty::mt {ty: ast_ty_to_ty(this, rscope, mt.ty), mutbl: mt.mutbl}
|
ty::mt {ty: ast_ty_to_ty(this, rscope, mt.ty), mutbl: mt.mutbl}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum PointerTy {
|
||||||
|
Box,
|
||||||
|
VStore(ty::vstore)
|
||||||
|
}
|
||||||
|
impl PointerTy {
|
||||||
|
fn expect_vstore(&self, tcx: ty::ctxt, span: Span, ty: &str) -> ty::vstore {
|
||||||
|
match *self {
|
||||||
|
Box => {
|
||||||
|
tcx.sess.span_err(span, format!("managed {} are not supported", ty));
|
||||||
|
// everything can be ~, so this is a worth substitute
|
||||||
|
ty::vstore_uniq
|
||||||
|
}
|
||||||
|
VStore(vst) => vst
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Handle @, ~, and & being able to mean strs and vecs.
|
// Handle @, ~, and & being able to mean strs and vecs.
|
||||||
// If a_seq_ty is a str or a vec, make it a str/vec.
|
// If a_seq_ty is a str or a vec, make it a str/vec.
|
||||||
// Also handle first-class trait types.
|
// Also handle first-class trait types.
|
||||||
|
@ -392,17 +409,18 @@ pub fn ast_ty_to_ty<AC:AstConv, RS:RegionScope>(
|
||||||
this: &AC,
|
this: &AC,
|
||||||
rscope: &RS,
|
rscope: &RS,
|
||||||
a_seq_ty: &ast::MutTy,
|
a_seq_ty: &ast::MutTy,
|
||||||
vst: ty::vstore,
|
ptr_ty: PointerTy,
|
||||||
constr: |ty::mt| -> ty::t)
|
constr: |ty::mt| -> ty::t)
|
||||||
-> ty::t {
|
-> ty::t {
|
||||||
let tcx = this.tcx();
|
let tcx = this.tcx();
|
||||||
debug!("mk_pointer(vst={:?})", vst);
|
debug!("mk_pointer(ptr_ty={:?})", ptr_ty);
|
||||||
|
|
||||||
match a_seq_ty.ty.node {
|
match a_seq_ty.ty.node {
|
||||||
ast::TyVec(ty) => {
|
ast::TyVec(ty) => {
|
||||||
|
let vst = ptr_ty.expect_vstore(tcx, a_seq_ty.ty.span, "vectors");
|
||||||
let mut mt = ast_ty_to_mt(this, rscope, ty);
|
let mut mt = ast_ty_to_mt(this, rscope, ty);
|
||||||
if a_seq_ty.mutbl == ast::MutMutable {
|
if a_seq_ty.mutbl == ast::MutMutable {
|
||||||
mt = ty::mt { ty: mt.ty, mutbl: a_seq_ty.mutbl };
|
mt.mutbl = ast::MutMutable;
|
||||||
}
|
}
|
||||||
debug!("&[]: vst={:?}", vst);
|
debug!("&[]: vst={:?}", vst);
|
||||||
return ty::mk_vec(tcx, mt, vst);
|
return ty::mk_vec(tcx, mt, vst);
|
||||||
|
@ -416,26 +434,19 @@ pub fn ast_ty_to_ty<AC:AstConv, RS:RegionScope>(
|
||||||
Some(&ast::DefPrimTy(ast::TyStr)) if
|
Some(&ast::DefPrimTy(ast::TyStr)) if
|
||||||
a_seq_ty.mutbl == ast::MutImmutable => {
|
a_seq_ty.mutbl == ast::MutImmutable => {
|
||||||
check_path_args(tcx, path, NO_TPS | NO_REGIONS);
|
check_path_args(tcx, path, NO_TPS | NO_REGIONS);
|
||||||
match vst {
|
let vst = ptr_ty.expect_vstore(tcx, path.span, "strings");
|
||||||
ty::vstore_box => {
|
|
||||||
tcx.sess.span_err(path.span,
|
|
||||||
"managed strings are not \
|
|
||||||
supported")
|
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
return ty::mk_str(tcx, vst);
|
return ty::mk_str(tcx, vst);
|
||||||
}
|
}
|
||||||
Some(&ast::DefTrait(trait_def_id)) => {
|
Some(&ast::DefTrait(trait_def_id)) => {
|
||||||
let result = ast_path_to_trait_ref(
|
let result = ast_path_to_trait_ref(
|
||||||
this, rscope, trait_def_id, None, path);
|
this, rscope, trait_def_id, None, path);
|
||||||
let trait_store = match vst {
|
let trait_store = match ptr_ty {
|
||||||
ty::vstore_box => ty::BoxTraitStore,
|
Box => ty::BoxTraitStore,
|
||||||
ty::vstore_uniq => ty::UniqTraitStore,
|
VStore(ty::vstore_uniq) => ty::UniqTraitStore,
|
||||||
ty::vstore_slice(r) => {
|
VStore(ty::vstore_slice(r)) => {
|
||||||
ty::RegionTraitStore(r)
|
ty::RegionTraitStore(r)
|
||||||
}
|
}
|
||||||
ty::vstore_fixed(..) => {
|
VStore(ty::vstore_fixed(..)) => {
|
||||||
tcx.sess.span_err(
|
tcx.sess.span_err(
|
||||||
path.span,
|
path.span,
|
||||||
"@trait, ~trait or &trait are the only supported \
|
"@trait, ~trait or &trait are the only supported \
|
||||||
|
@ -483,12 +494,11 @@ pub fn ast_ty_to_ty<AC:AstConv, RS:RegionScope>(
|
||||||
ast::TyBot => ty::mk_bot(),
|
ast::TyBot => ty::mk_bot(),
|
||||||
ast::TyBox(ty) => {
|
ast::TyBox(ty) => {
|
||||||
let mt = ast::MutTy { ty: ty, mutbl: ast::MutImmutable };
|
let mt = ast::MutTy { ty: ty, mutbl: ast::MutImmutable };
|
||||||
mk_pointer(this, rscope, &mt, ty::vstore_box,
|
mk_pointer(this, rscope, &mt, Box, |tmt| ty::mk_box(tcx, tmt.ty))
|
||||||
|tmt| ty::mk_box(tcx, tmt.ty))
|
|
||||||
}
|
}
|
||||||
ast::TyUniq(ty) => {
|
ast::TyUniq(ty) => {
|
||||||
let mt = ast::MutTy { ty: ty, mutbl: ast::MutImmutable };
|
let mt = ast::MutTy { ty: ty, mutbl: ast::MutImmutable };
|
||||||
mk_pointer(this, rscope, &mt, ty::vstore_uniq,
|
mk_pointer(this, rscope, &mt, VStore(ty::vstore_uniq),
|
||||||
|tmt| ty::mk_uniq(tcx, tmt.ty))
|
|tmt| ty::mk_uniq(tcx, tmt.ty))
|
||||||
}
|
}
|
||||||
ast::TyVec(ty) => {
|
ast::TyVec(ty) => {
|
||||||
|
@ -502,7 +512,7 @@ pub fn ast_ty_to_ty<AC:AstConv, RS:RegionScope>(
|
||||||
ast::TyRptr(ref region, ref mt) => {
|
ast::TyRptr(ref region, ref mt) => {
|
||||||
let r = opt_ast_region_to_region(this, rscope, ast_ty.span, region);
|
let r = opt_ast_region_to_region(this, rscope, ast_ty.span, region);
|
||||||
debug!("ty_rptr r={}", r.repr(this.tcx()));
|
debug!("ty_rptr r={}", r.repr(this.tcx()));
|
||||||
mk_pointer(this, rscope, mt, ty::vstore_slice(r),
|
mk_pointer(this, rscope, mt, VStore(ty::vstore_slice(r)),
|
||||||
|tmt| ty::mk_rptr(tcx, r, tmt))
|
|tmt| ty::mk_rptr(tcx, r, tmt))
|
||||||
}
|
}
|
||||||
ast::TyTup(ref fields) => {
|
ast::TyTup(ref fields) => {
|
||||||
|
|
|
@ -604,7 +604,7 @@ pub fn check_pat(pcx: &pat_ctxt, pat: &ast::Pat, expected: ty::t) {
|
||||||
ty::ty_vec(mt, vstore) => {
|
ty::ty_vec(mt, vstore) => {
|
||||||
let region_var = match vstore {
|
let region_var = match vstore {
|
||||||
ty::vstore_slice(r) => r,
|
ty::vstore_slice(r) => r,
|
||||||
ty::vstore_box | ty::vstore_uniq | ty::vstore_fixed(_) => {
|
ty::vstore_uniq | ty::vstore_fixed(_) => {
|
||||||
default_region_var
|
default_region_var
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -699,7 +699,6 @@ impl<'a> LookupContext<'a> {
|
||||||
let tcx = self.tcx();
|
let tcx = self.tcx();
|
||||||
let sty = ty::get(self_ty).sty.clone();
|
let sty = ty::get(self_ty).sty.clone();
|
||||||
match sty {
|
match sty {
|
||||||
ty_vec(mt, vstore_box) |
|
|
||||||
ty_vec(mt, vstore_uniq) |
|
ty_vec(mt, vstore_uniq) |
|
||||||
ty_vec(mt, vstore_slice(_)) | // NDM(#3148)
|
ty_vec(mt, vstore_slice(_)) | // NDM(#3148)
|
||||||
ty_vec(mt, vstore_fixed(_)) => {
|
ty_vec(mt, vstore_fixed(_)) => {
|
||||||
|
@ -728,7 +727,6 @@ impl<'a> LookupContext<'a> {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
ty_str(vstore_box) |
|
|
||||||
ty_str(vstore_uniq) |
|
ty_str(vstore_uniq) |
|
||||||
ty_str(vstore_fixed(_)) => {
|
ty_str(vstore_fixed(_)) => {
|
||||||
let entry = self.search_for_some_kind_of_autorefd_method(
|
let entry = self.search_for_some_kind_of_autorefd_method(
|
||||||
|
|
|
@ -1215,9 +1215,7 @@ pub mod guarantor {
|
||||||
}
|
}
|
||||||
ty::ty_box(..) |
|
ty::ty_box(..) |
|
||||||
ty::ty_ptr(..) |
|
ty::ty_ptr(..) |
|
||||||
ty::ty_vec(_, ty::vstore_box) |
|
ty::ty_trait(_, _, ty::BoxTraitStore, _, _) => {
|
||||||
ty::ty_trait(_, _, ty::BoxTraitStore, _, _) |
|
|
||||||
ty::ty_str(ty::vstore_box) => {
|
|
||||||
OtherPointer
|
OtherPointer
|
||||||
}
|
}
|
||||||
ty::ty_closure(ref closure_ty) => {
|
ty::ty_closure(ref closure_ty) => {
|
||||||
|
@ -1301,7 +1299,6 @@ pub mod guarantor {
|
||||||
let guarantor1 = match vstore {
|
let guarantor1 = match vstore {
|
||||||
ty::vstore_fixed(_) | ty::vstore_uniq => guarantor,
|
ty::vstore_fixed(_) | ty::vstore_uniq => guarantor,
|
||||||
ty::vstore_slice(r) => Some(r),
|
ty::vstore_slice(r) => Some(r),
|
||||||
ty::vstore_box => None
|
|
||||||
};
|
};
|
||||||
|
|
||||||
link_ref_bindings_in_pats(rcx, before, guarantor1);
|
link_ref_bindings_in_pats(rcx, before, guarantor1);
|
||||||
|
|
|
@ -67,7 +67,7 @@ we may want to adjust precisely when coercions occur.
|
||||||
|
|
||||||
use middle::ty::{AutoPtr, AutoBorrowVec, AutoBorrowFn, AutoBorrowObj};
|
use middle::ty::{AutoPtr, AutoBorrowVec, AutoBorrowFn, AutoBorrowObj};
|
||||||
use middle::ty::{AutoDerefRef};
|
use middle::ty::{AutoDerefRef};
|
||||||
use middle::ty::{vstore_slice, vstore_box, vstore_uniq};
|
use middle::ty::{vstore_slice, vstore_uniq};
|
||||||
use middle::ty::{mt};
|
use middle::ty::{mt};
|
||||||
use middle::ty;
|
use middle::ty;
|
||||||
use middle::typeck::infer::{CoerceResult, resolve_type, Coercion};
|
use middle::typeck::infer::{CoerceResult, resolve_type, Coercion};
|
||||||
|
@ -272,7 +272,6 @@ impl Coerce {
|
||||||
b.inf_str(self.get_ref().infcx));
|
b.inf_str(self.get_ref().infcx));
|
||||||
|
|
||||||
match *sty_a {
|
match *sty_a {
|
||||||
ty::ty_str(vstore_box) |
|
|
||||||
ty::ty_str(vstore_uniq) => {}
|
ty::ty_str(vstore_uniq) => {}
|
||||||
_ => {
|
_ => {
|
||||||
return self.subtype(a, b);
|
return self.subtype(a, b);
|
||||||
|
|
|
@ -736,7 +736,7 @@ impl<'a> ConstraintContext<'a> {
|
||||||
self.add_constraints_from_region(r, contra);
|
self.add_constraints_from_region(r, contra);
|
||||||
}
|
}
|
||||||
|
|
||||||
ty::vstore_fixed(_) | ty::vstore_uniq | ty::vstore_box => {
|
ty::vstore_fixed(_) | ty::vstore_uniq => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -260,7 +260,6 @@ pub fn vstore_to_str(cx: ctxt, vs: ty::vstore) -> ~str {
|
||||||
match vs {
|
match vs {
|
||||||
ty::vstore_fixed(n) => format!("{}", n),
|
ty::vstore_fixed(n) => format!("{}", n),
|
||||||
ty::vstore_uniq => ~"~",
|
ty::vstore_uniq => ~"~",
|
||||||
ty::vstore_box => ~"@",
|
|
||||||
ty::vstore_slice(r) => region_ptr_to_str(cx, r)
|
ty::vstore_slice(r) => region_ptr_to_str(cx, r)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2825,7 +2825,7 @@ impl Parser {
|
||||||
let hi = self.last_span.hi;
|
let hi = self.last_span.hi;
|
||||||
return @ast::Pat {
|
return @ast::Pat {
|
||||||
id: ast::DUMMY_NODE_ID,
|
id: ast::DUMMY_NODE_ID,
|
||||||
node: sub,
|
node: PatUniq(sub),
|
||||||
span: mk_sp(lo, hi)
|
span: mk_sp(lo, hi)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue