pub fn write_vstore(ecx: &EncodeContext,
ebml_w: &mut Encoder,
- vstore: ty::vstore) {
+ vstore: ty::Vstore) {
let ty_str_ctxt = &tyencode::ctxt {
diag: ecx.diag,
ds: def_to_str,
}
}
-fn parse_vstore(st: &mut PState, conv: conv_did) -> ty::vstore {
+fn parse_vstore(st: &mut PState, conv: conv_did) -> ty::Vstore {
assert_eq!(next(st), '/');
let c = peek(st);
if '0' <= c && c <= '9' {
let n = parse_uint(st);
assert_eq!(next(st), '|');
- return ty::vstore_fixed(n);
+ return ty::VstoreFixed(n);
}
match next(st) {
- '~' => ty::vstore_uniq,
- '&' => ty::vstore_slice(parse_region(st, conv)),
+ '~' => ty::VstoreUniq,
+ '&' => ty::VstoreSlice(parse_region(st, conv)),
c => st.tcx.sess.bug(format!("parse_vstore(): bad input '{}'", c))
}
}
}
}
-pub fn enc_vstore(w: &mut MemWriter, cx: &ctxt, v: ty::vstore) {
+pub fn enc_vstore(w: &mut MemWriter, cx: &ctxt, v: ty::Vstore) {
mywrite!(w, "/");
match v {
- ty::vstore_fixed(u) => mywrite!(w, "{}|", u),
- ty::vstore_uniq => mywrite!(w, "~"),
- ty::vstore_slice(r) => {
+ ty::VstoreFixed(u) => mywrite!(w, "{}|", u),
+ ty::VstoreUniq => mywrite!(w, "~"),
+ ty::VstoreSlice(r) => {
mywrite!(w, "&");
enc_region(w, cx, r);
}
trait ebml_writer_helpers {
fn emit_ty(&mut self, ecx: &e::EncodeContext, ty: ty::t);
- fn emit_vstore(&mut self, ecx: &e::EncodeContext, vstore: ty::vstore);
+ fn emit_vstore(&mut self, ecx: &e::EncodeContext, vstore: ty::Vstore);
fn emit_tys(&mut self, ecx: &e::EncodeContext, tys: &[ty::t]);
fn emit_type_param_def(&mut self,
ecx: &e::EncodeContext,
self.emit_opaque(|this| Ok(e::write_type(ecx, this, ty)));
}
- fn emit_vstore(&mut self, ecx: &e::EncodeContext, vstore: ty::vstore) {
+ fn emit_vstore(&mut self, ecx: &e::EncodeContext, vstore: ty::Vstore) {
self.emit_opaque(|this| Ok(e::write_vstore(ecx, this, vstore)));
}
}
not_useful
}
- ty::ty_vec(_, ty::vstore_fixed(n)) => {
+ ty::ty_vec(_, ty::VstoreFixed(n)) => {
is_useful_specialized(cx, m, v, vec(n), n, left_ty)
}
ty::ty_vec(..) => {
else if true_found { Some(val(const_bool(false))) }
else { Some(val(const_bool(true))) }
}
- ty::ty_vec(_, ty::vstore_fixed(n)) => {
+ ty::ty_vec(_, ty::VstoreFixed(n)) => {
let mut missing = true;
let mut wrong = false;
for r in m.iter() {
ty::ty_box(_) => {
n_box += 1;
}
- ty::ty_uniq(_) | ty::ty_str(ty::vstore_uniq) |
- ty::ty_vec(_, ty::vstore_uniq) |
+ ty::ty_uniq(_) | ty::ty_str(ty::VstoreUniq) |
+ ty::ty_vec(_, ty::VstoreUniq) |
ty::ty_trait(~ty::TyTrait { store: ty::UniqTraitStore, .. }) => {
n_uniq += 1;
}
fn check_deprecated_owned_vector(cx: &Context, e: &ast::Expr) {
let t = ty::expr_ty(cx.tcx, e);
match ty::get(t).sty {
- ty::ty_vec(_, ty::vstore_uniq) => {
+ ty::ty_vec(_, ty::VstoreUniq) => {
cx.span_lint(DeprecatedOwnedVector, e.span,
"use of deprecated `~[]` vector; replaced by `std::vec::Vec`")
}
match ty::get(t).sty {
ty::ty_uniq(_) |
ty::ty_trait(~ty::TyTrait { store: ty::UniqTraitStore, .. }) |
- ty::ty_vec(_, ty::vstore_uniq) |
- ty::ty_str(ty::vstore_uniq) |
+ ty::ty_vec(_, ty::VstoreUniq) |
+ ty::ty_str(ty::VstoreUniq) |
ty::ty_closure(~ty::ClosureTy {sigil: ast::OwnedSigil, ..}) => {
Some(deref_ptr(OwnedPtr))
}
ty::ty_rptr(r, mt) |
- ty::ty_vec(mt, ty::vstore_slice(r)) => {
+ ty::ty_vec(mt, ty::VstoreSlice(r)) => {
let kind = ty::BorrowKind::from_mutbl(mt.mutbl);
Some(deref_ptr(BorrowedPtr(kind, r)))
}
Some(deref_ptr(BorrowedPtr(kind, r)))
}
- ty::ty_str(ty::vstore_slice(r)) |
+ ty::ty_str(ty::VstoreSlice(r)) |
ty::ty_closure(~ty::ClosureTy {sigil: ast::BorrowedSigil,
region: r, ..}) => {
Some(deref_ptr(BorrowedPtr(ty::ImmBorrow, r)))
Some(deref_interior(InteriorField(PositionalField(0))))
}
- ty::ty_vec(_, ty::vstore_fixed(_)) |
- ty::ty_str(ty::vstore_fixed(_)) => {
+ ty::ty_vec(_, ty::VstoreFixed(_)) |
+ ty::ty_str(ty::VstoreFixed(_)) => {
Some(deref_interior(InteriorElement(element_kind(t))))
}
*/
match ty::get(slice_ty).sty {
- ty::ty_vec(slice_mt, ty::vstore_slice(slice_r)) => {
+ ty::ty_vec(slice_mt, ty::VstoreSlice(slice_r)) => {
(slice_mt.mutbl, slice_r)
}
let slice_len = Sub(bcx, len, slice_len_offset);
let slice_ty = ty::mk_vec(bcx.tcx(),
ty::mt {ty: vt.unit_ty, mutbl: ast::MutImmutable},
- ty::vstore_slice(ty::ReStatic)
+ ty::VstoreSlice(ty::ReStatic)
);
let scratch = rvalue_scratch_datum(bcx, slice_ty, "");
Store(bcx, slice_begin,
}
match ty::get(rhs_t).sty {
- ty::ty_str(ty::vstore_uniq) => {
+ ty::ty_str(ty::VstoreUniq) => {
let scratch_lhs = alloca(cx, val_ty(lhs), "__lhs");
Store(cx, lhs, scratch_lhs);
let scratch_rhs = alloca(cx, val_ty(rhs), "__rhs");
// FIXME #6750 ~Trait cannot be directly marked as
// noalias because the actual object pointer is nested.
ty::ty_uniq(..) | // ty::ty_trait(_, _, ty::UniqTraitStore, _, _) |
- ty::ty_vec(_, ty::vstore_uniq) | ty::ty_str(ty::vstore_uniq) => {
+ ty::ty_vec(_, ty::VstoreUniq) | ty::ty_str(ty::VstoreUniq) => {
unsafe {
llvm::LLVMAddReturnAttribute(llfn, lib::llvm::NoAliasAttribute as c_uint);
}
// FIXME #6750 ~Trait cannot be directly marked as
// noalias because the actual object pointer is nested.
ty::ty_uniq(..) | // ty::ty_trait(_, _, ty::UniqTraitStore, _, _) |
- ty::ty_vec(_, ty::vstore_uniq) | ty::ty_str(ty::vstore_uniq) |
+ ty::ty_vec(_, ty::VstoreUniq) | ty::ty_str(ty::VstoreUniq) |
ty::ty_closure(~ty::ClosureTy {sigil: ast::OwnedSigil, ..}) => {
unsafe {
llvm::LLVMAddAttribute(llarg, lib::llvm::NoAliasAttribute as c_uint);
}
})
}
- ty::ty_str(ty::vstore_fixed(_)) |
- ty::ty_vec(_, ty::vstore_fixed(_)) => {
+ ty::ty_str(ty::VstoreFixed(_)) |
+ ty::ty_vec(_, ty::VstoreFixed(_)) => {
let (base, len) = tvec::get_base_and_byte_len(cx, av, t);
let unit_ty = ty::sequence_element_type(cx.tcx(), t);
cx = tvec::iter_vec_raw(cx, base, unit_ty, len, f);
match ty::get(ret_ty).sty {
// `~` pointer return values never alias because ownership
// is transferred
- ty::ty_uniq(..) | ty::ty_vec(_, ty::vstore_uniq) => {
+ ty::ty_uniq(..) | ty::ty_vec(_, ty::VstoreUniq) => {
attrs.push((0, NoAliasAttribute));
}
_ => {}
match ty::get(t).sty {
ty::ty_float(_) => MonoFloat,
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::VstoreUniq) | ty::ty_vec(_, ty::VstoreUniq) |
ty::ty_bare_fn(..) => MonoNonNull,
// Is that everything? Would closures or slices qualify?
_ => MonoBits
assert_eq!(abi::slice_elt_base, 0);
assert_eq!(abi::slice_elt_len, 1);
match ty::get(ty).sty {
- ty::ty_vec(_, ty::vstore_fixed(len)) => {
+ ty::ty_vec(_, ty::VstoreFixed(len)) => {
llconst = C_struct(cx, [
llptr,
C_uint(cx, len)
let (arr, len) = match ty::get(bt).sty {
ty::ty_vec(_, vstore) | ty::ty_str(vstore) =>
match vstore {
- ty::vstore_fixed(u) =>
+ ty::VstoreFixed(u) =>
(bv, C_uint(cx, u)),
- ty::vstore_slice(_) => {
+ ty::VstoreSlice(_) => {
let e1 = const_get_elt(cx, bv, [0]);
(const_deref_ptr(cx, e1), const_get_elt(cx, bv, [1]))
},
ty::ty_str(ref vstore) => {
let i8_t = ty::mk_i8();
match *vstore {
- ty::vstore_fixed(len) => {
+ ty::VstoreFixed(len) => {
fixed_vec_metadata(cx, i8_t, len, usage_site_span)
},
- ty::vstore_uniq => {
+ ty::VstoreUniq => {
let vec_metadata = vec_metadata(cx, i8_t, usage_site_span);
pointer_type_metadata(cx, t, vec_metadata)
}
- ty::vstore_slice(_region) => {
+ ty::VstoreSlice(_region) => {
vec_slice_metadata(cx, t, i8_t, usage_site_span)
}
}
},
ty::ty_vec(ref mt, ref vstore) => {
match *vstore {
- ty::vstore_fixed(len) => {
+ ty::VstoreFixed(len) => {
fixed_vec_metadata(cx, mt.ty, len, usage_site_span)
}
- ty::vstore_uniq => {
+ ty::VstoreUniq => {
let vec_metadata = vec_metadata(cx, mt.ty, usage_site_span);
pointer_type_metadata(cx, t, vec_metadata)
}
- ty::vstore_slice(_) => {
+ ty::VstoreSlice(_) => {
vec_slice_metadata(cx, t, mt.ty, usage_site_span)
}
}
// real one, but it will have the same runtime representation
let slice_ty = ty::mk_vec(tcx,
ty::mt { ty: unit_ty, mutbl: ast::MutImmutable },
- ty::vstore_slice(ty::ReStatic));
+ ty::VstoreSlice(ty::ReStatic));
let scratch = rvalue_scratch_datum(bcx, slice_ty, "__adjust");
Store(bcx, base, GEPi(bcx, scratch.val, [0u, abi::slice_elt_base]));
}
}
- ty::ty_vec(mt, ty::vstore_uniq) if !ty::type_needs_drop(tcx, mt.ty) =>
+ ty::ty_vec(mt, ty::VstoreUniq) if !ty::type_needs_drop(tcx, mt.ty) =>
ty::mk_uniq(tcx, ty::mk_i8()),
_ => t
trans_exchange_free(bcx, llbox)
})
}
- ty::ty_vec(_, ty::vstore_uniq) | ty::ty_str(ty::vstore_uniq) => {
+ ty::ty_vec(_, ty::VstoreUniq) | ty::ty_str(ty::VstoreUniq) => {
let llbox = Load(bcx, v0);
let not_null = IsNotNull(bcx, llbox);
with_cond(bcx, not_null, |bcx| {
// We're careful to not use first class aggregates here because that
// will kick us off fast isel. (Issue #4352.)
let bcx = self.bcx;
- let str_vstore = ty::vstore_slice(ty::ReStatic);
+ let str_vstore = ty::VstoreSlice(ty::ReStatic);
let str_ty = ty::mk_str(bcx.tcx(), str_vstore);
let scratch = rvalue_scratch_datum(bcx, str_ty, "");
let len = C_uint(bcx.ccx(), s.get().len());
pub fn vstore_name_and_extra(&mut self,
t: ty::t,
- vstore: ty::vstore)
+ vstore: ty::Vstore)
-> (~str, Vec<ValueRef> ) {
match vstore {
- ty::vstore_fixed(n) => {
+ ty::VstoreFixed(n) => {
let extra = (vec!(self.c_uint(n))).append(self.c_size_and_align(t).as_slice());
(~"fixed", extra)
}
- ty::vstore_slice(_) => (~"slice", Vec::new()),
- ty::vstore_uniq => (~"uniq", Vec::new()),
+ ty::VstoreSlice(_) => (~"slice", Vec::new()),
+ ty::VstoreUniq => (~"uniq", Vec::new()),
}
}
let fixed_ty = ty::mk_vec(bcx.tcx(),
ty::mt {ty: vt.unit_ty,
mutbl: ast::MutMutable},
- ty::vstore_fixed(count));
+ ty::VstoreFixed(count));
let llfixed_ty = type_of::type_of(bcx.ccx(), fixed_ty).ptr_to();
let llfixed_casted = BitCast(bcx, llfixed, llfixed_ty);
let cleanup_scope = cleanup::temporary_scope(bcx.tcx(), content_expr.id);
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_str(bcx.tcx(), ty::vstore_uniq);
+ let typ = ty::mk_str(bcx.tcx(), ty::VstoreUniq);
let lldestval = rvalue_scratch_datum(bcx,
typ,
"");
let vstore = match ty::get(vec_ty).sty {
ty::ty_str(vst) | ty::ty_vec(_, vst) => vst,
- _ => ty::vstore_uniq
+ _ => ty::VstoreUniq
};
match vstore {
- ty::vstore_fixed(n) => {
+ ty::VstoreFixed(n) => {
let base = GEPi(bcx, llval, [0u, 0u]);
let len = Mul(bcx, C_uint(ccx, n), vt.llunit_size);
(base, len)
}
- ty::vstore_slice(_) => {
+ ty::VstoreSlice(_) => {
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]));
let len = Mul(bcx, count, vt.llunit_size);
(base, len)
}
- ty::vstore_uniq => {
+ ty::VstoreUniq => {
assert!(type_is_immediate(bcx.ccx(), vec_ty));
let body = Load(bcx, llval);
(get_dataptr(bcx, body), get_fill(bcx, body))
let vstore = match ty::get(vec_ty).sty {
ty::ty_str(vst) | ty::ty_vec(_, vst) => vst,
- _ => ty::vstore_uniq
+ _ => ty::VstoreUniq
};
match vstore {
- ty::vstore_fixed(n) => {
+ ty::VstoreFixed(n) => {
let base = GEPi(bcx, llval, [0u, 0u]);
(base, C_uint(ccx, n))
}
- ty::vstore_slice(_) => {
+ ty::VstoreSlice(_) => {
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]));
(base, count)
}
- ty::vstore_uniq => {
+ ty::VstoreUniq => {
assert!(type_is_immediate(bcx.ccx(), vec_ty));
let body = Load(bcx, llval);
(get_dataptr(bcx, body), UDiv(bcx, get_fill(bcx, body), vt.llunit_size))
ty::ty_uint(t) => Type::uint_from_ty(cx, t),
ty::ty_float(t) => Type::float_from_ty(cx, t),
- ty::ty_str(ty::vstore_uniq) |
- ty::ty_vec(_, ty::vstore_uniq) |
+ ty::ty_str(ty::VstoreUniq) |
+ ty::ty_vec(_, ty::VstoreUniq) |
ty::ty_box(..) |
ty::ty_uniq(..) |
ty::ty_ptr(..) |
ty::ty_rptr(..) => Type::i8p(cx),
- ty::ty_str(ty::vstore_slice(..)) |
- ty::ty_vec(_, ty::vstore_slice(..)) => {
+ ty::ty_str(ty::VstoreSlice(..)) |
+ ty::ty_vec(_, ty::VstoreSlice(..)) => {
Type::struct_(cx, [Type::i8p(cx), Type::i8p(cx)], false)
}
ty::ty_closure(..) => Type::struct_(cx, [Type::i8p(cx), Type::i8p(cx)], false),
ty::ty_trait(..) => Type::opaque_trait(cx),
- ty::ty_str(ty::vstore_fixed(size)) => Type::array(&Type::i8(cx), size as u64),
- ty::ty_vec(mt, ty::vstore_fixed(size)) => {
+ ty::ty_str(ty::VstoreFixed(size)) => Type::array(&Type::i8(cx), size as u64),
+ ty::ty_vec(mt, ty::VstoreFixed(size)) => {
Type::array(&sizing_type_of(cx, mt.ty), size as u64)
}
ty::ty_int(t) => Type::int_from_ty(cx, t),
ty::ty_uint(t) => Type::uint_from_ty(cx, t),
ty::ty_float(t) => Type::float_from_ty(cx, t),
- ty::ty_str(ty::vstore_uniq) => {
+ ty::ty_str(ty::VstoreUniq) => {
Type::vec(cx, &Type::i8(cx)).ptr_to()
}
ty::ty_enum(did, ref substs) => {
ty::ty_uniq(typ) => {
type_of(cx, typ).ptr_to()
}
- ty::ty_vec(ref mt, ty::vstore_uniq) => {
+ ty::ty_vec(ref mt, ty::VstoreUniq) => {
Type::vec(cx, &type_of(cx, mt.ty)).ptr_to()
}
ty::ty_ptr(ref mt) => type_of(cx, mt.ty).ptr_to(),
ty::ty_rptr(_, ref mt) => type_of(cx, mt.ty).ptr_to(),
- ty::ty_vec(ref mt, ty::vstore_slice(_)) => {
+ ty::ty_vec(ref mt, ty::VstoreSlice(_)) => {
let p_ty = type_of(cx, mt.ty).ptr_to();
let u_ty = Type::uint_from_ty(cx, ast::TyU);
Type::struct_(cx, [p_ty, u_ty], false)
}
- ty::ty_str(ty::vstore_slice(_)) => {
+ ty::ty_str(ty::VstoreSlice(_)) => {
// This means we get a nicer name in the output
cx.tn.find_type("str_slice").unwrap()
}
- ty::ty_str(ty::vstore_fixed(n)) => {
+ ty::ty_str(ty::VstoreFixed(n)) => {
Type::array(&Type::i8(cx), (n + 1u) as u64)
}
- ty::ty_vec(ref mt, ty::vstore_fixed(n)) => {
+ ty::ty_vec(ref mt, ty::VstoreFixed(n)) => {
Type::array(&type_of(cx, mt.ty), n as u64)
}
}
#[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash, Show)]
-pub enum vstore {
- vstore_fixed(uint),
- vstore_uniq,
- vstore_slice(Region)
+pub enum Vstore {
+ VstoreFixed(uint),
+ VstoreUniq,
+ VstoreSlice(Region)
}
#[deriving(Clone, Eq, TotalEq, Hash, Encodable, Decodable, Show)]
ty_int(ast::IntTy),
ty_uint(ast::UintTy),
ty_float(ast::FloatTy),
- ty_str(vstore),
+ ty_str(Vstore),
ty_enum(DefId, substs),
ty_box(t),
ty_uniq(t),
- ty_vec(mt, vstore),
+ ty_vec(mt, Vstore),
ty_ptr(mt),
ty_rptr(Region, mt),
ty_bare_fn(BareFnTy),
terr_regions_no_overlap(Region, Region),
terr_regions_insufficiently_polymorphic(BoundRegion, Region),
terr_regions_overly_polymorphic(BoundRegion, Region),
- terr_vstores_differ(terr_vstore_kind, expected_found<vstore>),
+ terr_vstores_differ(terr_vstore_kind, expected_found<Vstore>),
terr_trait_stores_differ(terr_vstore_kind, expected_found<TraitStore>),
terr_in_field(@type_err, ast::Ident),
terr_sorts(expected_found<t>),
return f;
}
match &st {
- &ty_str(vstore_slice(r)) => {
+ &ty_str(VstoreSlice(r)) => {
flags |= rflags(r);
}
- &ty_vec(ref mt, vstore_slice(r)) => {
+ &ty_vec(ref mt, VstoreSlice(r)) => {
flags |= rflags(r);
flags |= get(mt.ty).flags;
}
#[inline]
pub fn mk_char() -> t { mk_prim_t(&primitives::TY_CHAR) }
-pub fn mk_str(cx: &ctxt, t: vstore) -> t {
+pub fn mk_str(cx: &ctxt, t: Vstore) -> t {
mk_t(cx, ty_str(t))
}
mk_ptr(cx, mt {ty: mk_nil(), mutbl: ast::MutImmutable})
}
-pub fn mk_vec(cx: &ctxt, tm: mt, t: vstore) -> t {
+pub fn mk_vec(cx: &ctxt, tm: mt, t: Vstore) -> t {
mk_t(cx, ty_vec(tm, t))
}
pub fn type_is_structural(ty: t) -> bool {
match get(ty).sty {
ty_struct(..) | ty_tup(_) | ty_enum(..) | ty_closure(_) | ty_trait(..) |
- ty_vec(_, vstore_fixed(_)) | ty_str(vstore_fixed(_)) |
- ty_vec(_, vstore_slice(_)) | ty_str(vstore_slice(_))
+ ty_vec(_, VstoreFixed(_)) | ty_str(VstoreFixed(_)) |
+ ty_vec(_, VstoreSlice(_)) | ty_str(VstoreSlice(_))
=> true,
_ => false
}
pub fn type_is_unique(ty: t) -> bool {
match get(ty).sty {
- ty_uniq(_) | ty_vec(_, vstore_uniq) | ty_str(vstore_uniq) => true,
+ ty_uniq(_) | ty_vec(_, VstoreUniq) | ty_str(VstoreUniq) => true,
_ => false
}
}
!needs_unwind_cleanup
}
ty_uniq(_) |
- ty_str(vstore_uniq) |
- ty_vec(_, vstore_uniq) => {
+ ty_str(VstoreUniq) |
+ ty_vec(_, VstoreUniq) => {
// Once we're inside a box, the annihilator will find
// it and destroy it.
if !encountered_box {
TC::None
}
- ty_str(vstore_uniq) => {
+ ty_str(VstoreUniq) => {
TC::OwnsOwned
}
borrowed_contents(r, mt.mutbl))
}
- ty_vec(mt, vstore_uniq) => {
+ ty_vec(mt, VstoreUniq) => {
tc_mt(cx, mt, cache).owned_pointer()
}
- ty_vec(ref mt, vstore_slice(r)) => {
+ ty_vec(ref mt, VstoreSlice(r)) => {
tc_ty(cx, mt.ty, cache).reference(
borrowed_contents(r, mt.mutbl))
}
- ty_vec(mt, vstore_fixed(_)) => {
+ ty_vec(mt, VstoreFixed(_)) => {
tc_mt(cx, mt, cache)
}
- ty_str(vstore_slice(r)) => {
+ ty_str(VstoreSlice(r)) => {
borrowed_contents(r, ast::MutImmutable)
}
- ty_str(vstore_fixed(_)) => {
+ ty_str(VstoreFixed(_)) => {
TC::None
}
// fixed length vectors need special treatment compared to
// normal vectors, since they don't necessarily have the
// possibilty to have length zero.
- ty_vec(_, vstore_fixed(0)) => false, // don't need no contents
- ty_vec(mt, vstore_fixed(_)) => type_requires(cx, seen, r_ty, mt.ty),
+ ty_vec(_, VstoreFixed(0)) => false, // don't need no contents
+ ty_vec(mt, VstoreFixed(_)) => type_requires(cx, seen, r_ty, mt.ty),
ty_nil |
ty_bot |
}
// Fixed-length vectors.
// FIXME(#11924) Behavior undecided for zero-length vectors.
- ty_vec(mt, vstore_fixed(_)) => {
+ ty_vec(mt, VstoreFixed(_)) => {
type_structurally_recursive(cx, seen, mt.ty)
}
ty: t) -> Region {
match get(ty).sty {
ty_rptr(r, _) => r,
- ty_vec(_, vstore_slice(r)) => r,
- ty_str(vstore_slice(r)) => r,
+ ty_vec(_, VstoreSlice(r)) => r,
+ ty_str(VstoreSlice(r)) => r,
ref s => {
tcx.sess.span_bug(
span,
ty: ty::t) -> ty::t {
match get(ty).sty {
ty_vec(mt, _) => {
- ty::mk_vec(cx, mt {ty: mt.ty, mutbl: m}, vstore_slice(r))
+ ty::mk_vec(cx, mt {ty: mt.ty, mutbl: m}, VstoreSlice(r))
}
ty_str(_) => {
- ty::mk_str(cx, vstore_slice(r))
+ ty::mk_str(cx, VstoreSlice(r))
}
ref s => {
return t_norm;
}
- fn fold_vstore(&mut self, vstore: vstore) -> vstore {
+ fn fold_vstore(&mut self, vstore: Vstore) -> Vstore {
match vstore {
- vstore_fixed(..) | vstore_uniq => vstore,
- vstore_slice(_) => vstore_slice(ReStatic)
+ VstoreFixed(..) | VstoreUniq => vstore,
+ VstoreSlice(_) => VstoreSlice(ReStatic)
}
}
}
}
};
- let vstore = |state: &mut sip::SipState, v: vstore| {
+ let vstore = |state: &mut sip::SipState, v: Vstore| {
match v {
- vstore_fixed(_) => 0u8.hash(state),
- vstore_uniq => 1u8.hash(state),
- vstore_slice(r) => {
+ VstoreFixed(_) => 0u8.hash(state),
+ VstoreUniq => 1u8.hash(state),
+ VstoreSlice(r) => {
2u8.hash(state);
region(state, r);
}
r
}
- fn fold_vstore(&mut self, vstore: ty::vstore) -> ty::vstore {
+ fn fold_vstore(&mut self, vstore: ty::Vstore) -> ty::Vstore {
super_fold_vstore(self, vstore)
}
}
pub fn super_fold_vstore<T:TypeFolder>(this: &mut T,
- vstore: ty::vstore)
- -> ty::vstore {
+ vstore: ty::Vstore)
+ -> ty::Vstore {
match vstore {
- ty::vstore_fixed(i) => ty::vstore_fixed(i),
- ty::vstore_uniq => ty::vstore_uniq,
- ty::vstore_slice(r) => ty::vstore_slice(this.fold_region(r)),
+ ty::VstoreFixed(i) => ty::VstoreFixed(i),
+ ty::VstoreUniq => ty::VstoreUniq,
+ ty::VstoreSlice(r) => ty::VstoreSlice(this.fold_region(r)),
}
}
tcx.sess.span_err(ast_ty.span,
"bare `str` is not a type");
// return /something/ so they can at least get more errors
- Some(ty::mk_str(tcx, ty::vstore_uniq))
+ Some(ty::mk_str(tcx, ty::VstoreUniq))
}
}
}
enum PointerTy {
Box,
- VStore(ty::vstore)
+ VStore(ty::Vstore)
}
impl PointerTy {
- fn expect_vstore(&self, tcx: &ty::ctxt, span: Span, ty: &str) -> ty::vstore {
+ 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
+ ty::VstoreUniq
}
VStore(vst) => vst
}
let result = ast_path_to_trait_ref(
this, rscope, trait_def_id, None, path);
let trait_store = match ptr_ty {
- VStore(ty::vstore_uniq) => ty::UniqTraitStore,
- VStore(ty::vstore_slice(r)) => {
+ VStore(ty::VstoreUniq) => ty::UniqTraitStore,
+ VStore(ty::VstoreSlice(r)) => {
ty::RegionTraitStore(r)
}
_ => {
}
ast::TyUniq(ty) => {
let mt = ast::MutTy { ty: ty, mutbl: ast::MutImmutable };
- mk_pointer(this, rscope, &mt, VStore(ty::vstore_uniq),
+ mk_pointer(this, rscope, &mt, VStore(ty::VstoreUniq),
|tmt| ty::mk_uniq(tcx, tmt.ty))
}
ast::TyVec(ty) => {
tcx.sess.span_err(ast_ty.span, "bare `[]` is not a type");
// return /something/ so they can at least get more errors
- ty::mk_vec(tcx, ast_ty_to_mt(this, rscope, ty), ty::vstore_uniq)
+ ty::mk_vec(tcx, ast_ty_to_mt(this, rscope, ty), ty::VstoreUniq)
}
ast::TyPtr(ref mt) => {
ty::mk_ptr(tcx, ast_mt_to_mt(this, rscope, mt))
ast::TyRptr(ref region, ref mt) => {
let r = opt_ast_region_to_region(this, rscope, ast_ty.span, region);
debug!("ty_rptr r={}", r.repr(this.tcx()));
- mk_pointer(this, rscope, mt, VStore(ty::vstore_slice(r)),
+ mk_pointer(this, rscope, mt, VStore(ty::VstoreSlice(r)),
|tmt| ty::mk_rptr(tcx, r, tmt))
}
ast::TyTup(ref fields) => {
match *r {
const_eval::const_int(i) =>
ty::mk_vec(tcx, ast_ty_to_mt(this, rscope, ty),
- ty::vstore_fixed(i as uint)),
+ ty::VstoreFixed(i as uint)),
const_eval::const_uint(i) =>
ty::mk_vec(tcx, ast_ty_to_mt(this, rscope, ty),
- ty::vstore_fixed(i as uint)),
+ ty::VstoreFixed(i as uint)),
_ => {
tcx.sess.span_fatal(
ast_ty.span, "expected constant expr for vector length");
expected) {
ty::ty_vec(mt, vstore) => {
let region_var = match vstore {
- ty::vstore_slice(r) => r,
- ty::vstore_uniq => {
+ ty::VstoreSlice(r) => r,
+ ty::VstoreUniq => {
fcx.type_error_message(pat.span,
|_| {
~"unique vector patterns are no \
None);
default_region_var
}
- ty::vstore_fixed(_) => {
+ ty::VstoreFixed(_) => {
default_region_var
}
};
Some(slice_pat) => {
let slice_ty = ty::mk_vec(tcx,
ty::mt {ty: elt_type.ty, mutbl: elt_type.mutbl},
- ty::vstore_slice(region_var)
+ ty::VstoreSlice(region_var)
);
check_pat(pcx, slice_pat, slice_ty);
}
autoderefs: autoderefs+1,
autoref: Some(ty::AutoPtr(region, self_mt.mutbl))})
}
- ty::ty_vec(self_mt, vstore_slice(_)) => {
+ ty::ty_vec(self_mt, VstoreSlice(_)) => {
let region =
self.infcx().next_region_var(infer::Autoref(self.span));
- (ty::mk_vec(tcx, self_mt, vstore_slice(region)),
+ (ty::mk_vec(tcx, self_mt, VstoreSlice(region)),
ty::AutoDerefRef {
autoderefs: autoderefs,
autoref: Some(ty::AutoBorrowVec(region, self_mt.mutbl))})
let tcx = self.tcx();
let sty = ty::get(self_ty).sty.clone();
match sty {
- ty_vec(mt, vstore_uniq) |
- ty_vec(mt, vstore_slice(_)) | // NDM(#3148)
- ty_vec(mt, vstore_fixed(_)) => {
+ ty_vec(mt, VstoreUniq) |
+ ty_vec(mt, VstoreSlice(_)) |
+ ty_vec(mt, VstoreFixed(_)) => {
// First try to borrow to a slice
let entry = self.search_for_some_kind_of_autorefd_method(
AutoBorrowVec, autoderefs, [MutImmutable, MutMutable],
|m,r| ty::mk_vec(tcx,
ty::mt {ty:mt.ty, mutbl:m},
- vstore_slice(r)));
+ VstoreSlice(r)));
if entry.is_some() { return entry; }
|m,r| {
let slice_ty = ty::mk_vec(tcx,
ty::mt {ty:mt.ty, mutbl:m},
- vstore_slice(r));
+ VstoreSlice(r));
// NB: we do not try to autoref to a mutable
// pointer. That would be creating a pointer
// to a temporary pointer (the borrowed
})
}
- ty_str(vstore_uniq) |
- ty_str(vstore_fixed(_)) => {
+ ty_str(VstoreUniq) |
+ ty_str(VstoreFixed(_)) => {
let entry = self.search_for_some_kind_of_autorefd_method(
AutoBorrowVec, autoderefs, [MutImmutable],
- |_m,r| ty::mk_str(tcx, vstore_slice(r)));
+ |_m,r| ty::mk_str(tcx, VstoreSlice(r)));
if entry.is_some() { return entry; }
self.search_for_some_kind_of_autorefd_method(
AutoBorrowVecRef, autoderefs, [MutImmutable],
|m,r| {
- let slice_ty = ty::mk_str(tcx, vstore_slice(r));
+ let slice_ty = ty::mk_str(tcx, VstoreSlice(r));
ty::mk_rptr(tcx, r, ty::mt {ty:slice_ty, mutbl:m})
})
}
let tcx = fcx.ccx.tcx;
match lit.node {
- ast::LitStr(..) => ty::mk_str(tcx, ty::vstore_slice(ty::ReStatic)),
+ ast::LitStr(..) => ty::mk_str(tcx, ty::VstoreSlice(ty::ReStatic)),
ast::LitBinary(..) => {
ty::mk_vec(tcx, ty::mt{ ty: ty::mk_u8(), mutbl: ast::MutImmutable },
- ty::vstore_slice(ty::ReStatic))
+ ty::VstoreSlice(ty::ReStatic))
}
ast::LitChar(_) => ty::mk_char(),
ast::LitInt(_, t) => ty::mk_mach_int(t),
check_expr_has_type(fcx, *e, t);
}
let typ = ty::mk_vec(tcx, ty::mt {ty: t, mutbl: ast::MutImmutable},
- ty::vstore_fixed(args.len()));
+ ty::VstoreFixed(args.len()));
fcx.write_ty(id, typ);
}
ast::ExprRepeat(element, count_expr) => {
}
else {
let t = ty::mk_vec(tcx, ty::mt {ty: t, mutbl: ast::MutImmutable},
- ty::vstore_fixed(count));
+ ty::VstoreFixed(count));
fcx.write_ty(id, t);
}
}
pub fn ast_expr_vstore_to_vstore(fcx: &FnCtxt,
e: &ast::Expr,
v: ast::ExprVstore)
- -> ty::vstore {
+ -> ty::Vstore {
match v {
- ast::ExprVstoreUniq => ty::vstore_uniq,
+ ast::ExprVstoreUniq => ty::VstoreUniq,
ast::ExprVstoreSlice | ast::ExprVstoreMutSlice => {
match e.node {
ast::ExprLit(..) => {
// string literals and *empty slices* live in static memory
- ty::vstore_slice(ty::ReStatic)
+ ty::VstoreSlice(ty::ReStatic)
}
ast::ExprVec(ref elements) if elements.len() == 0 => {
// string literals and *empty slices* live in static memory
- ty::vstore_slice(ty::ReStatic)
+ ty::VstoreSlice(ty::ReStatic)
}
ast::ExprRepeat(..) |
ast::ExprVec(..) => {
match fcx.tcx().region_maps.temporary_scope(e.id) {
Some(scope) => {
let r = ty::ReScope(scope);
- ty::vstore_slice(r)
+ ty::VstoreSlice(r)
}
None => {
// this slice occurs in a static somewhere
- ty::vstore_slice(ty::ReStatic)
+ ty::VstoreSlice(ty::ReStatic)
}
}
}
let r_index_expr = ty::ReScope(index_expr.id);
match ty::get(indexed_ty).sty {
- ty::ty_str(ty::vstore_slice(r_ptr)) |
- ty::ty_vec(_, ty::vstore_slice(r_ptr)) => {
+ ty::ty_str(ty::VstoreSlice(r_ptr)) |
+ ty::ty_vec(_, ty::VstoreSlice(r_ptr)) => {
rcx.fcx.mk_subr(true, infer::IndexSlice(index_expr.span),
r_index_expr, r_ptr);
}
fn fold_ty(&mut self, ty: ty::t) -> ty::t {
match ty::get(ty).sty {
ty::ty_rptr(r, ref mt) |
- ty::ty_vec(ref mt, ty::vstore_slice(r)) => {
+ ty::ty_vec(ref mt, ty::VstoreSlice(r)) => {
self.relate(r);
self.stack.push(r);
ty_fold::super_fold_ty(self, mt.ty);
use middle::ty::{AutoPtr, AutoBorrowVec, AutoBorrowFn, AutoBorrowObj};
use middle::ty::{AutoDerefRef};
-use middle::ty::{vstore_slice, vstore_uniq};
+use middle::ty::{VstoreSlice, VstoreUniq};
use middle::ty::{mt};
use middle::ty;
use middle::typeck::infer::{CoerceResult, resolve_type, Coercion};
});
}
- ty::ty_str(vstore_slice(_)) => {
+ ty::ty_str(VstoreSlice(_)) => {
return self.unpack_actual_value(a, |sty_a| {
self.coerce_borrowed_string(a, sty_a, b)
});
}
- ty::ty_vec(mt_b, vstore_slice(_)) => {
+ ty::ty_vec(mt_b, VstoreSlice(_)) => {
return self.unpack_actual_value(a, |sty_a| {
self.coerce_borrowed_vector(a, sty_a, b, mt_b)
});
b.inf_str(self.get_ref().infcx));
match *sty_a {
- ty::ty_str(vstore_uniq) => {}
+ ty::ty_str(VstoreUniq) => {}
_ => {
return self.subtype(a, b);
}
};
let r_a = self.get_ref().infcx.next_region_var(Coercion(self.get_ref().trace));
- let a_borrowed = ty::mk_str(self.get_ref().infcx.tcx, vstore_slice(r_a));
+ let a_borrowed = ty::mk_str(self.get_ref().infcx.tcx, VstoreSlice(r_a));
if_ok!(self.subtype(a_borrowed, b));
Ok(Some(@AutoDerefRef(AutoDerefRef {
autoderefs: 0,
let a_borrowed = ty::mk_vec(self.get_ref().infcx.tcx,
mt {ty: ty_inner, mutbl: mt_b.mutbl},
- vstore_slice(r_borrow));
+ VstoreSlice(r_borrow));
if_ok!(sub.tys(a_borrowed, b));
Ok(Some(@AutoDerefRef(AutoDerefRef {
autoderefs: 0,
fn vstores(&self,
vk: ty::terr_vstore_kind,
- a: ty::vstore,
- b: ty::vstore)
- -> cres<ty::vstore> {
+ a: ty::Vstore,
+ b: ty::Vstore)
+ -> cres<ty::Vstore> {
debug!("{}.vstores(a={:?}, b={:?})", self.tag(), a, b);
match (a, b) {
- (ty::vstore_slice(a_r), ty::vstore_slice(b_r)) => {
+ (ty::VstoreSlice(a_r), ty::VstoreSlice(b_r)) => {
self.contraregions(a_r, b_r).and_then(|r| {
- Ok(ty::vstore_slice(r))
+ Ok(ty::VstoreSlice(r))
})
}
}
}
- /// Adds constraints appropriate for a vector with vstore `vstore`
+ /// Adds constraints appropriate for a vector with Vstore `vstore`
/// appearing in a context with ambient variance `variance`
fn add_constraints_from_vstore(&mut self,
- vstore: ty::vstore,
+ vstore: ty::Vstore,
variance: VarianceTermPtr<'a>) {
match vstore {
- ty::vstore_slice(r) => {
+ ty::VstoreSlice(r) => {
let contra = self.contravariant(variance);
self.add_constraints_from_region(r, contra);
}
- ty::vstore_fixed(_) | ty::vstore_uniq => {
- }
+ ty::VstoreFixed(_) | ty::VstoreUniq => {}
}
}
return format!("{}{}{}{}", mstr, before, ty_to_str(cx, m.ty), after);
}
-pub fn vstore_to_str(cx: &ctxt, vs: ty::vstore) -> ~str {
+pub fn vstore_to_str(cx: &ctxt, vs: ty::Vstore) -> ~str {
match vs {
- ty::vstore_fixed(n) => format!("{}", n),
- ty::vstore_uniq => ~"~",
- ty::vstore_slice(r) => region_ptr_to_str(cx, r)
+ ty::VstoreFixed(n) => format!("{}", n),
+ ty::VstoreUniq => ~"~",
+ ty::VstoreSlice(r) => region_ptr_to_str(cx, r)
}
}
pub fn trait_store_to_str(cx: &ctxt, s: ty::TraitStore) -> ~str {
match s {
- ty::UniqTraitStore => ~"~",
- ty::RegionTraitStore(r) => region_ptr_to_str(cx, r)
+ ty::UniqTraitStore => ~"~",
+ ty::RegionTraitStore(r) => region_ptr_to_str(cx, r)
}
}
-pub fn vstore_ty_to_str(cx: &ctxt, mt: &mt, vs: ty::vstore) -> ~str {
+pub fn vstore_ty_to_str(cx: &ctxt, mt: &mt, vs: ty::Vstore) -> ~str {
match vs {
- ty::vstore_fixed(_) => {
+ ty::VstoreFixed(_) => {
format!("[{}, .. {}]", mt_to_str(cx, mt), vstore_to_str(cx, vs))
}
_ => {
}
}
-impl Repr for ty::vstore {
+impl Repr for ty::Vstore {
fn repr(&self, tcx: &ctxt) -> ~str {
vstore_to_str(tcx, *self)
}