auto merge of #12180 : eddyb/rust/rm-ty_type, r=nikomatsakis

This commit is contained in:
bors 2014-02-12 04:36:43 -08:00
commit fb12aebbd8
17 changed files with 29 additions and 57 deletions

View File

@ -372,7 +372,6 @@ fn parse_ty(st: &mut PState, conv: conv_did) -> ty::t {
'F' => {
return ty::mk_bare_fn(st.tcx, parse_bare_fn_ty(st, |x,y| conv(x,y)));
}
'Y' => return ty::mk_type(st.tcx),
'#' => {
let pos = parse_hex(st);
assert_eq!(next(st), ':');

View File

@ -328,7 +328,6 @@ fn enc_sty(w: &mut MemWriter, cx: @ctxt, st: &ty::sty) {
ty::ty_self(did) => {
mywrite!(w, "s{}|", (cx.ds)(did));
}
ty::ty_type => mywrite!(w, "Y"),
ty::ty_struct(def, ref substs) => {
mywrite!(w, "a[{}|", (cx.ds)(def));
enc_substs(w, cx, substs);

View File

@ -598,19 +598,8 @@ pub fn compare_scalar_types<'a>(
ty::ty_int(_) => rslt(cx, f(signed_int)),
ty::ty_uint(_) => rslt(cx, f(unsigned_int)),
ty::ty_float(_) => rslt(cx, f(floating_point)),
ty::ty_type => {
rslt(
controlflow::trans_fail(
cx, None,
InternedString::new("attempt to compare values of type \
type")),
C_nil())
}
_ => {
// Should never get here, because t is scalar.
cx.sess().bug("non-scalar type passed to \
compare_scalar_types")
}
_ => cx.sess().bug("non-scalar type passed to compare_scalar_types")
}
}

View File

@ -152,8 +152,12 @@ pub fn mk_closure_tys(tcx: ty::ctxt,
return cdata_ty;
}
pub fn allocate_cbox<'a>(
bcx: &'a Block<'a>,
fn tuplify_box_ty(tcx: ty::ctxt, t: ty::t) -> ty::t {
let ptr = ty::mk_imm_ptr(tcx, ty::mk_i8());
ty::mk_tup(tcx, ~[ty::mk_uint(), ty::mk_nil_ptr(tcx), ptr, ptr, t])
}
fn allocate_cbox<'a>(bcx: &'a Block<'a>,
sigil: ast::Sigil,
cdata_ty: ty::t)
-> Result<'a> {

View File

@ -520,19 +520,6 @@ pub fn val_ty(v: ValueRef) -> Type {
}
}
// Let T be the content of a box @T. tuplify_box_ty(t) returns the
// representation of @T as a tuple (i.e., the ty::t version of what T_box()
// returns).
pub fn tuplify_box_ty(tcx: ty::ctxt, t: ty::t) -> ty::t {
let ptr = ty::mk_ptr(
tcx,
ty::mt {ty: ty::mk_i8(), mutbl: ast::MutImmutable}
);
return ty::mk_tup(tcx, ~[ty::mk_uint(), ty::mk_type(tcx),
ptr, ptr,
t]);
}
// LLVM constant constructors.
pub fn C_null(t: Type) -> ValueRef {
unsafe {

View File

@ -368,8 +368,7 @@ pub fn visit_ty(&mut self, t: ty::t) {
let extra = ~[self.c_uint(p.idx)];
self.visit("param", extra)
}
ty::ty_self(..) => self.leaf("self"),
ty::ty_type => self.leaf("type")
ty::ty_self(..) => self.leaf("self")
}
}

View File

@ -119,8 +119,7 @@ pub fn sizing_type_of(cx: &CrateContext, t: ty::t) -> Type {
ty::ty_box(..) |
ty::ty_uniq(..) |
ty::ty_ptr(..) |
ty::ty_rptr(..) |
ty::ty_type => Type::i8p(),
ty::ty_rptr(..) => Type::i8p(),
ty::ty_str(ty::vstore_slice(..)) |
ty::ty_vec(_, ty::vstore_slice(..)) => {
@ -263,7 +262,6 @@ pub fn type_of(cx: &CrateContext, t: ty::t) -> Type {
Type::struct_([fn_ty, Type::i8p()], false)
}
ty::ty_trait(..) => Type::opaque_trait(),
ty::ty_type => cx.tydesc_type.ptr_to(),
ty::ty_tup(..) => {
let repr = adt::represent_type(cx, t);
adt::type_of(cx, repr)

View File

@ -756,7 +756,6 @@ pub enum sty {
// on non-useful type error messages)
// "Fake" types, used for trans purposes
ty_type, // type_desc*
ty_unboxed_vec(mt),
}
@ -1181,7 +1180,7 @@ fn sflags(substs: &substs) -> uint {
flags |= get(mt.ty).flags;
}
&ty_nil | &ty_bool | &ty_char | &ty_int(_) | &ty_float(_) | &ty_uint(_) |
&ty_str(_) | &ty_type => {}
&ty_str(_) => {}
// You might think that we could just return ty_err for
// any type containing ty_err as a component, and get
// rid of the has_ty_err flag -- likewise for ty_bot (with
@ -1444,8 +1443,6 @@ pub fn mk_param(cx: ctxt, n: uint, k: DefId) -> t {
mk_t(cx, ty_param(param_ty { idx: n, def_id: k }))
}
pub fn mk_type(cx: ctxt) -> t { mk_t(cx, ty_type) }
pub fn walk_ty(ty: t, f: |t|) {
maybe_walk_ty(ty, |t| { f(t); true });
}
@ -1456,7 +1453,7 @@ pub fn maybe_walk_ty(ty: t, f: |t| -> bool) {
}
match get(ty).sty {
ty_nil | ty_bot | ty_bool | ty_char | ty_int(_) | ty_uint(_) | ty_float(_) |
ty_str(_) | ty_type | ty_self(_) |
ty_str(_) | ty_self(_) |
ty_infer(_) | ty_param(_) | ty_err => {}
ty_box(ty) | ty_uniq(ty) => maybe_walk_ty(ty, f),
ty_vec(ref tm, _) | ty_unboxed_vec(ref tm) | ty_ptr(ref tm) |
@ -1730,7 +1727,7 @@ pub fn type_is_unique(ty: t) -> bool {
pub fn type_is_scalar(ty: t) -> bool {
match get(ty).sty {
ty_nil | ty_bool | ty_char | ty_int(_) | ty_float(_) | ty_uint(_) |
ty_infer(IntVar(_)) | ty_infer(FloatVar(_)) | ty_type |
ty_infer(IntVar(_)) | ty_infer(FloatVar(_)) |
ty_bare_fn(..) | ty_ptr(_) => true,
_ => false
}
@ -2216,8 +2213,6 @@ fn tc_ty(cx: ctxt,
}
ty_unboxed_vec(mt) => TC::InteriorUnsized | tc_mt(cx, mt, cache),
ty_type => TC::None,
ty_err => {
cx.sess.bug("asked to compute contents of error type");
}
@ -2401,7 +2396,6 @@ fn subtypes_require(cx: ctxt, seen: &mut ~[DefId],
ty_err |
ty_param(_) |
ty_self(_) |
ty_type |
ty_vec(_, _) |
ty_unboxed_vec(_) => {
false
@ -2628,7 +2622,7 @@ pub fn type_is_pod(cx: ctxt, ty: t) -> bool {
match get(ty).sty {
// Scalar types
ty_nil | ty_bot | ty_bool | ty_char | ty_int(_) | ty_float(_) | ty_uint(_) |
ty_type | ty_ptr(_) | ty_bare_fn(_) => result = true,
ty_ptr(_) | ty_bare_fn(_) => result = true,
// Boxed types
ty_box(_) | ty_uniq(_) | ty_closure(_) |
ty_str(vstore_uniq) |
@ -3556,7 +3550,7 @@ fn vars_in_type(ty: t) -> ~[TyVid] {
pub fn ty_sort_str(cx: ctxt, t: t) -> ~str {
match get(t).sty {
ty_nil | ty_bot | ty_bool | ty_char | ty_int(_) |
ty_uint(_) | ty_float(_) | ty_str(_) | ty_type => {
ty_uint(_) | ty_float(_) | ty_str(_) => {
::util::ppaux::ty_to_str(cx, t)
}
@ -5120,9 +5114,8 @@ fn iter<T: IterBytes>(hash: &mut SipState, t: &T) {
}
ty_infer(_) => unreachable!(),
ty_err => hash.input([23]),
ty_type => hash.input([24]),
ty_unboxed_vec(m) => {
hash.input([25]);
hash.input([24]);
mt(&mut hash, m);
}
}

View File

@ -187,8 +187,7 @@ pub fn super_fold_sty<T:TypeFolder>(this: &mut T,
ty::ty_str(this.fold_vstore(vst))
}
ty::ty_nil | ty::ty_bot | ty::ty_bool | ty::ty_char |
ty::ty_int(_) | ty::ty_uint(_) |
ty::ty_float(_) | ty::ty_type |
ty::ty_int(_) | ty::ty_uint(_) | ty::ty_float(_) |
ty::ty_err | ty::ty_infer(_) |
ty::ty_param(..) | ty::ty_self(_) => {
(*sty).clone()

View File

@ -788,7 +788,7 @@ fn search_for_autoptrd_method(&self, self_ty: ty::t, autoderefs: uint)
ty_err => None,
ty_unboxed_vec(_) | ty_type | ty_infer(TyVar(_)) => {
ty_unboxed_vec(_) | ty_infer(TyVar(_)) => {
self.bug(format!("unexpected type: {}",
self.ty_to_str(self_ty)));
}

View File

@ -23,7 +23,7 @@
use middle::ty::{ty_str, ty_vec, ty_float, ty_infer, ty_int, ty_nil};
use middle::ty::{ty_param, ty_param_bounds_and_ty, ty_ptr};
use middle::ty::{ty_rptr, ty_self, ty_struct, ty_trait, ty_tup};
use middle::ty::{ty_type, ty_uint, ty_uniq, ty_bare_fn, ty_closure};
use middle::ty::{ty_uint, ty_uniq, ty_bare_fn, ty_closure};
use middle::ty::{ty_unboxed_vec, type_is_ty_var};
use middle::subst::Subst;
use middle::ty;
@ -82,7 +82,7 @@ fn get_base_type(inference_context: &InferCtxt,
ty_nil | ty_bot | ty_bool | ty_char | ty_int(..) | ty_uint(..) | ty_float(..) |
ty_str(..) | ty_vec(..) | ty_bare_fn(..) | ty_closure(..) | ty_tup(..) |
ty_infer(..) | ty_param(..) | ty_self(..) | ty_type |
ty_infer(..) | ty_param(..) | ty_self(..) |
ty_unboxed_vec(..) | ty_err | ty_box(_) |
ty_uniq(_) | ty_ptr(_) | ty_rptr(_, _) => {
debug!("(getting base type) no base type; found {:?}",

View File

@ -715,8 +715,7 @@ fn add_constraints_from_ty(&mut self,
self.add_constraints_from_sig(sig, variance);
}
ty::ty_infer(..) | ty::ty_err |
ty::ty_type | ty::ty_unboxed_vec(..) => {
ty::ty_infer(..) | ty::ty_err | ty::ty_unboxed_vec(..) => {
self.tcx().sess.bug(
format!("unexpected type encountered in \
variance inference: {}",

View File

@ -18,7 +18,7 @@
ReEmpty};
use middle::ty::{ty_bool, ty_char, ty_bot, ty_box, ty_struct, ty_enum};
use middle::ty::{ty_err, ty_str, ty_vec, ty_float, ty_bare_fn, ty_closure};
use middle::ty::{ty_nil, ty_param, ty_ptr, ty_rptr, ty_self, ty_tup, ty_type};
use middle::ty::{ty_nil, ty_param, ty_ptr, ty_rptr, ty_self, ty_tup};
use middle::ty::{ty_uniq, ty_trait, ty_int, ty_uint, ty_unboxed_vec, ty_infer};
use middle::ty;
use middle::typeck;
@ -454,7 +454,6 @@ fn push_sig_to_str(cx: ctxt,
region_ptr_to_str(cx, r) + mt_to_str(cx, tm)
}
ty_unboxed_vec(ref tm) => { format!("unboxed_vec<{}>", mt_to_str(cx, tm)) }
ty_type => ~"type",
ty_tup(ref elems) => {
let strs = elems.map(|elem| ty_to_str(cx, *elem));
~"(" + strs.connect(",") + ")"

View File

@ -442,6 +442,8 @@ fn visit_self(&mut self) -> bool {
true
}
// NOTE Remove after next snapshot.
#[cfg(stage0)]
fn visit_type(&mut self) -> bool {
if ! self.inner.visit_type() { return false; }
true

View File

@ -601,6 +601,9 @@ fn visit_trait(&mut self, name: &str) -> bool {
fn visit_param(&mut self, _i: uint) -> bool { true }
fn visit_self(&mut self) -> bool { true }
// NOTE Remove after next snapshot.
#[cfg(stage0)]
fn visit_type(&mut self) -> bool { true }
}

View File

@ -160,6 +160,9 @@ fn visit_leave_fn(&mut self, purity: uint, proto: uint,
fn visit_trait(&mut self, name: &str) -> bool;
fn visit_param(&mut self, i: uint) -> bool;
fn visit_self(&mut self) -> bool;
// NOTE Remove after next snapshot.
#[cfg(stage0)]
fn visit_type(&mut self) -> bool;
}

View File

@ -138,7 +138,6 @@ fn visit_leave_fn(&mut self, _purity: uint, _proto: uint,
fn visit_trait(&mut self, _name: &str) -> bool { true }
fn visit_param(&mut self, _i: uint) -> bool { true }
fn visit_self(&mut self) -> bool { true }
fn visit_type(&mut self) -> bool { true }
}
fn visit_ty<T>(v: &mut MyVisitor) {