match e.node {
ast::ExprCast(ref expr, ref ty) => {
let t_t = ast_ty_to_ty(cx, &infer::new_infer_ctxt(cx.tcx), &**ty);
- if ty::get(ty::expr_ty(cx.tcx, &**expr)).sty == ty::get(t_t).sty {
+ if ty::expr_ty(cx.tcx, &**expr) == t_t {
cx.span_lint(UNUSED_TYPECASTS, ty.span, "unnecessary type cast");
}
}
},
_ => {
let t = ty::expr_ty(cx.tcx, &**expr);
- match ty::get(t).sty {
+ match t.sty {
ty::ty_uint(_) => {
cx.span_lint(UNSIGNED_NEGATION, e.span,
"negation of unsigned int variable may \
}
if is_shift_binop(binop) {
- let opt_ty_bits = match ty::get(ty::expr_ty(cx.tcx, &**l)).sty {
+ let opt_ty_bits = match ty::expr_ty(cx.tcx, &**l).sty {
ty::ty_int(t) => Some(int_ty_bits(t, cx.sess().target.int_type)),
ty::ty_uint(t) => Some(uint_ty_bits(t, cx.sess().target.uint_type)),
_ => None
}
},
ast::ExprLit(ref lit) => {
- match ty::get(ty::expr_ty(cx.tcx, e)).sty {
+ match ty::expr_ty(cx.tcx, e).sty {
ty::ty_int(t) => {
match lit.node {
ast::LitInt(v, ast::SignedIntLit(_, ast::Plus)) |
// Normalize the binop so that the literal is always on the RHS in
// the comparison
let norm_binop = if swap { rev_binop(binop) } else { binop };
- match ty::get(ty::expr_ty(tcx, expr)).sty {
+ match ty::expr_ty(tcx, expr).sty {
ty::ty_int(int_ty) => {
let (min, max) = int_ty_range(int_ty);
let lit_val: i64 = match lit.node {
span: Span, ty: Ty<'tcx>) {
let mut n_uniq = 0i;
ty::fold_ty(cx.tcx, ty, |t| {
- match ty::get(t).sty {
+ match t.sty {
ty::ty_uniq(_) |
ty::ty_closure(box ty::ClosureTy {
store: ty::UniqTraitStore,
}
let did = match item.node {
ast::ItemImpl(..) => {
- match ty::get(ty::node_id_to_type(cx.tcx, item.id)).sty {
+ match ty::node_id_to_type(cx.tcx, item.id).sty {
ty::ty_enum(did, _) => did,
ty::ty_struct(did, _) => did,
_ => return,
let t = ty::expr_ty(cx.tcx, expr);
let mut warned = false;
- match ty::get(t).sty {
+ match t.sty {
ty::ty_tup(ref tys) if tys.is_empty() => return,
ty::ty_bool => return,
ty::ty_struct(did, _) |
let ctor_ty = item_type(ast::DefId { krate: cdata.cnum, node: id},
item, tcx, cdata);
let name = item_name(&*intr, item);
- let (ctor_ty, arg_tys) = match ty::get(ctor_ty).sty {
+ let (ctor_ty, arg_tys) = match ctor_ty.sty {
ty::ty_bare_fn(ref f) =>
(Some(ctor_ty), f.sig.inputs.clone()),
_ => // Nullary or struct enum variant.
None => {}
}
let pos = w.tell().unwrap();
- enc_sty(w, cx, &ty::get(t).sty);
+ enc_sty(w, cx, &t.sty);
let end = w.tell().unwrap();
let len = end - pos;
fn estimate_sz(u: u64) -> u64 {
mc::cat_downcast(ref b) |
mc::cat_interior(ref b, _) => {
- match ty::get(b.ty).sty {
+ match b.ty.sty {
ty::ty_struct(did, _) | ty::ty_enum(did, _) => {
if ty::has_dtor(bccx.tcx, did) {
Some(cmt.clone())
mc::cat_downcast(ref b) |
mc::cat_interior(ref b, _) => {
- match ty::get(b.ty).sty {
+ match b.ty.sty {
ty::ty_struct(did, _)
| ty::ty_enum(did, _) if ty::has_dtor(bccx.tcx, did) => {
bccx.span_err(
fn move_suggestion<'tcx>(tcx: &ty::ctxt<'tcx>, ty: Ty<'tcx>,
default_msgs: (&'static str, &'static str))
-> (&'static str, &'static str) {
- match ty::get(ty).sty {
+ match ty.sty {
ty::ty_closure(box ty::ClosureTy {
store: ty::RegionTraitStore(..),
..
pats: Vec<&Pat>, left_ty: Ty) -> P<Pat> {
let pats_len = pats.len();
let mut pats = pats.into_iter().map(|p| P((*p).clone()));
- let pat = match ty::get(left_ty).sty {
+ let pat = match left_ty.sty {
ty::ty_tup(_) => ast::PatTup(pats.collect()),
ty::ty_enum(cid, _) | ty::ty_struct(cid, _) => {
}
ty::ty_rptr(_, ty::mt { ty, .. }) => {
- match ty::get(ty).sty {
+ match ty.sty {
ty::ty_vec(_, Some(n)) => match ctor {
&Single => {
assert_eq!(pats_len, n);
/// the column of patterns being analyzed.
fn all_constructors(cx: &MatchCheckCtxt, left_ty: Ty,
max_slice_length: uint) -> Vec<Constructor> {
- match ty::get(left_ty).sty {
+ match left_ty.sty {
ty::ty_bool =>
[true, false].iter().map(|b| ConstantValue(const_bool(*b))).collect(),
- ty::ty_rptr(_, ty::mt { ty, .. }) => match ty::get(ty).sty {
+ ty::ty_rptr(_, ty::mt { ty, .. }) => match ty.sty {
ty::ty_vec(_, None) =>
range_inclusive(0, max_slice_length).map(|length| Slice(length)).collect(),
_ => vec!(Single)
ast::PatRange(ref lo, ref hi) =>
vec!(ConstantRange(eval_const_expr(cx.tcx, &**lo), eval_const_expr(cx.tcx, &**hi))),
ast::PatVec(ref before, ref slice, ref after) =>
- match ty::get(left_ty).sty {
+ match left_ty.sty {
ty::ty_vec(_, Some(_)) => vec!(Single),
_ => if slice.is_some() {
range_inclusive(before.len() + after.len(), max_slice_length)
/// For instance, a tuple pattern (_, 42u, Some([])) has the arity of 3.
/// A struct pattern's arity is the number of fields it contains, etc.
pub fn constructor_arity(cx: &MatchCheckCtxt, ctor: &Constructor, ty: Ty) -> uint {
- match ty::get(ty).sty {
+ match ty.sty {
ty::ty_tup(ref fs) => fs.len(),
ty::ty_uniq(_) => 1u,
- ty::ty_rptr(_, ty::mt { ty, .. }) => match ty::get(ty).sty {
+ ty::ty_rptr(_, ty::mt { ty, .. }) => match ty.sty {
ty::ty_vec(_, None) => match *ctor {
Slice(length) => length,
ConstantValue(_) => 0u,
let node_ty = ty::node_id_to_type(self.tcx, e.id);
- match ty::get(node_ty).sty {
+ match node_ty.sty {
ty::ty_struct(did, _) |
ty::ty_enum(did, _) if ty::has_dtor(self.tcx, did) => {
self.tcx.sess.span_err(e.span,
$const_type:ident,
$target_ty:ty
)),*
- }) => (match ty::get(ety).sty {
+ }) => (match ety.sty {
$($ty_pat => {
match $val {
const_bool(b) => Ok($const_type(b as $intermediate_ty as $target_ty)),
}
fn handle_field_access(&mut self, lhs: &ast::Expr, name: &ast::Ident) {
- match ty::get(ty::expr_ty_adjusted(self.tcx, lhs)).sty {
+ match ty::expr_ty_adjusted(self.tcx, lhs).sty {
ty::ty_struct(id, _) => {
let fields = ty::lookup_struct_fields(self.tcx, id);
let field_id = fields.iter()
}
fn handle_tup_field_access(&mut self, lhs: &ast::Expr, idx: uint) {
- match ty::get(ty::expr_ty_adjusted(self.tcx, lhs)).sty {
+ match ty::expr_ty_adjusted(self.tcx, lhs).sty {
ty::ty_struct(id, _) => {
let fields = ty::lookup_struct_fields(self.tcx, id);
let field_id = fields[idx].id;
}
fn type_is_unsafe_function(ty: Ty) -> bool {
- match ty::get(ty).sty {
+ match ty.sty {
ty::ty_bare_fn(ref f) => f.fn_style == ast::UnsafeFn,
ty::ty_closure(ref f) => f.fn_style == ast::UnsafeFn,
_ => false,
};
debug!("effect: checking index with base type {}",
ppaux::ty_to_string(self.tcx, base_type));
- match ty::get(base_type).sty {
- ty::ty_uniq(ty) | ty::ty_rptr(_, ty::mt{ty, ..}) => match ty::get(ty).sty {
+ match base_type.sty {
+ ty::ty_uniq(ty) | ty::ty_rptr(_, ty::mt{ty, ..}) => match ty.sty {
ty::ty_str => {
span_err!(self.tcx.sess, e.span, E0134,
"modification of string types is not allowed");
let base_type = ty::node_id_to_type(self.tcx, base.id);
debug!("effect: unary case, base type is {}",
ppaux::ty_to_string(self.tcx, base_type));
- match ty::get(base_type).sty {
+ match base_type.sty {
ty::ty_ptr(_) => {
self.require_unsafe(expr.span,
"dereference of unsafe pointer")
let callee_ty = ty::expr_ty_adjusted(self.tcx(), callee);
debug!("walk_callee: callee={} callee_ty={}",
callee.repr(self.tcx()), callee_ty.repr(self.tcx()));
- match ty::get(callee_ty).sty {
+ match callee_ty.sty {
ty::ty_bare_fn(..) => {
self.consume_expr(callee);
}
// Select just those fields of the `with`
// expression that will actually be used
- let with_fields = match ty::get(with_cmt.ty).sty {
+ let with_fields = match with_cmt.ty.sty {
ty::ty_struct(did, ref substs) => {
ty::struct_fields(self.tcx(), did, substs)
}
Some(method_ty) => {
let cmt = return_if_err!(self.mc.cat_expr_autoderefd(expr, i));
let self_ty = ty::ty_fn_args(method_ty)[0];
- let (m, r) = match ty::get(self_ty).sty {
+ let (m, r) = match self_ty.sty {
ty::ty_rptr(r, ref m) => (m.mutbl, r),
_ => self.tcx().sess.span_bug(expr.span,
format!("bad overloaded deref type {}",
* are to be considered bound.
*/
- match ty::get(ty).sty {
+ match ty.sty {
ty::ty_bool => Some(BoolSimplifiedType),
ty::ty_char => Some(CharSimplifiedType),
ty::ty_int(int_type) => Some(IntSimplifiedType(int_type)),
-> bool {
let mut result = false;
ty::maybe_walk_ty(typ, |typ| {
- match ty::get(typ).sty {
+ match typ.sty {
ty::ty_uniq(_) | ty::ty_ptr(_) | ty::ty_rptr(..) |
ty::ty_bare_fn(..) | ty::ty_closure(..) => {
false
impl<'a, 'tcx> IntrinsicCheckingVisitor<'a, 'tcx> {
fn def_id_is_transmute(&self, def_id: DefId) -> bool {
- let intrinsic = match ty::get(ty::lookup_item_type(self.tcx, def_id).ty).sty {
+ let intrinsic = match ty::lookup_item_type(self.tcx, def_id).ty.sty {
ty::ty_bare_fn(ref bfty) => bfty.abi == RustIntrinsic,
_ => return false
};
match ty::resolve_expr(self.tcx, expr) {
DefFn(did, _) if self.def_id_is_transmute(did) => {
let typ = ty::node_id_to_type(self.tcx, expr.id);
- match ty::get(typ).sty {
+ match typ.sty {
ty_bare_fn(ref bare_fn_ty)
if bare_fn_ty.abi == RustIntrinsic => {
if let ty::FnConverging(to) = bare_fn_ty.sig.output {
impl<'a, 'tcx> Liveness<'a, 'tcx> {
fn fn_ret(&self, id: NodeId) -> ty::FnOutput<'tcx> {
let fn_ty = ty::node_id_to_type(self.ir.tcx, id);
- match ty::get(fn_ty).sty {
+ match fn_ty.sty {
ty::ty_unboxed_closure(closure_def_id, _, _) =>
self.ir.tcx.unboxed_closures()
.borrow()
None if body.stmts.len() > 0 =>
match body.stmts.last().unwrap().node {
ast::StmtSemi(ref e, _) => {
- let t_stmt = ty::expr_ty(self.ir.tcx, &**e);
- ty::get(t_stmt).sty == ty::get(t_ret).sty
+ ty::expr_ty(self.ir.tcx, &**e) == t_ret
},
_ => false
},
// derefable (we model an index as the combination of a deref and then a
// pointer adjustment).
pub fn opt_deref_kind(t: Ty) -> Option<deref_kind> {
- match ty::get(t).sty {
+ match t.sty {
ty::ty_uniq(_) |
ty::ty_closure(box ty::ClosureTy {store: ty::UniqTraitStore, ..}) => {
Some(deref_ptr(OwnedPtr))
def::DefUpvar(var_id, fn_node_id, _) => {
let ty = if_ok!(self.node_ty(fn_node_id));
- match ty::get(ty).sty {
+ match ty.sty {
ty::ty_closure(ref closure_ty) => {
// Translate old closure type info into unboxed
// closure kind/capture mode
-> cmt<'tcx> {
match self.typer.temporary_scope(id) {
Some(scope) => {
- match ty::get(expr_ty).sty {
+ match expr_ty.sty {
ty::ty_vec(_, Some(0)) => self.cat_rvalue(id, span, ty::ReStatic, expr_ty),
_ => self.cat_rvalue(id, span, ty::ReScope(scope), expr_ty)
}
* to recurse through rptrs.
*/
- match ty::get(slice_ty).sty {
- ty::ty_rptr(r, ref mt) => match ty::get(mt.ty).sty {
+ match slice_ty.sty {
+ ty::ty_rptr(r, ref mt) => match mt.ty.sty {
ty::ty_vec(_, None) => (mt.mutbl, r),
_ => vec_slice_info(tcx, pat, mt.ty),
},
}
fn element_kind(t: Ty) -> ElementKind {
- match ty::get(t).sty {
+ match t.sty {
ty::ty_rptr(_, ty::mt{ty, ..}) |
- ty::ty_uniq(ty) => match ty::get(ty).sty {
+ ty::ty_uniq(ty) => match ty.sty {
ty::ty_vec(_, None) => VecElement,
_ => OtherElement
},
}
let struct_type = ty::lookup_item_type(self.tcx, id).ty;
- let struct_desc = match ty::get(struct_type).sty {
+ let struct_desc = match struct_type.sty {
ty::ty_struct(_, _) =>
format!("struct `{}`", ty::item_path_str(self.tcx, id)),
// struct variant fields have inherited visibility
fn visit_expr(&mut self, expr: &ast::Expr) {
match expr.node {
ast::ExprField(ref base, ident, _) => {
- match ty::get(ty::expr_ty_adjusted(self.tcx, &**base)).sty {
+ match ty::expr_ty_adjusted(self.tcx, &**base).sty {
ty::ty_struct(id, _) => {
self.check_field(expr.span, id, NamedField(ident.node));
}
}
}
ast::ExprTupField(ref base, idx, _) => {
- match ty::get(ty::expr_ty_adjusted(self.tcx, &**base)).sty {
+ match ty::expr_ty_adjusted(self.tcx, &**base).sty {
ty::ty_struct(id, _) => {
self.check_field(expr.span, id, UnnamedField(idx.node));
}
}
}
ast::ExprStruct(_, ref fields, _) => {
- match ty::get(ty::expr_ty(self.tcx, expr)).sty {
+ match ty::expr_ty(self.tcx, expr).sty {
ty::ty_struct(id, _) => {
for field in (*fields).iter() {
self.check_field(expr.span, id,
match pattern.node {
ast::PatStruct(_, ref fields, _) => {
- match ty::get(ty::pat_ty(self.tcx, pattern)).sty {
+ match ty::pat_ty(self.tcx, pattern).sty {
ty::ty_struct(id, _) => {
for field in fields.iter() {
self.check_field(pattern.span, id,
// Patterns which bind no fields are allowable (the path is check
// elsewhere).
ast::PatEnum(_, Some(ref fields)) => {
- match ty::get(ty::pat_ty(self.tcx, pattern)).sty {
+ match ty::pat_ty(self.tcx, pattern).sty {
ty::ty_struct(id, _) => {
for (i, field) in fields.iter().enumerate() {
match field.node {
}
self.ty_stack_depth += 1;
- let t1 = match ty::get(t).sty {
+ let t1 = match t.sty {
ty::ty_param(p) => {
self.ty_for_param(p, t)
}
pub fn ty_is_local<'tcx>(tcx: &ty::ctxt<'tcx>, ty: Ty<'tcx>) -> bool {
debug!("ty_is_local({})", ty.repr(tcx));
- match ty::get(ty).sty {
+ match ty.sty {
ty::ty_bool |
ty::ty_char |
ty::ty_int(..) |
};
let self_ty = self.infcx.shallow_resolve(obligation.self_ty());
- let (closure_def_id, substs) = match ty::get(self_ty).sty {
+ let (closure_def_id, substs) = match self_ty.sty {
ty::ty_unboxed_closure(id, _, ref substs) => (id, substs.clone()),
ty::ty_infer(ty::TyVar(_)) => {
candidates.ambiguous = true;
-> Result<BuiltinBoundConditions<'tcx>,SelectionError<'tcx>>
{
let self_ty = self.infcx.shallow_resolve(self_ty);
- return match ty::get(self_ty).sty {
+ return match self_ty.sty {
ty::ty_infer(ty::IntVar(_)) |
ty::ty_infer(ty::FloatVar(_)) |
ty::ty_uint(_) |
}
}
-pub fn get<'tcx>(ty: Ty<'tcx>) -> Ty<'tcx> {
- ty
-}
-
-pub fn tbox_has_flag(tb: &TyS, flag: TypeFlags) -> bool {
- tb.flags.intersects(flag)
-}
pub fn type_has_params(ty: Ty) -> bool {
- tbox_has_flag(get(ty), HAS_PARAMS)
+ ty.flags.intersects(HAS_PARAMS)
}
pub fn type_has_self(ty: Ty) -> bool {
- tbox_has_flag(get(ty), HAS_SELF)
+ ty.flags.intersects(HAS_SELF)
}
pub fn type_has_ty_infer(ty: Ty) -> bool {
- tbox_has_flag(get(ty), HAS_TY_INFER)
+ ty.flags.intersects(HAS_TY_INFER)
}
pub fn type_needs_infer(ty: Ty) -> bool {
- tbox_has_flag(get(ty), HAS_TY_INFER | HAS_RE_INFER)
+ ty.flags.intersects(HAS_TY_INFER | HAS_RE_INFER)
}
pub fn type_has_late_bound_regions(ty: Ty) -> bool {
- get(ty).flags.intersects(HAS_RE_LATE_BOUND)
+ ty.flags.intersects(HAS_RE_LATE_BOUND)
}
pub fn type_has_escaping_regions(ty: Ty) -> bool {
}
pub fn type_escapes_depth(ty: Ty, depth: uint) -> bool {
- get(ty).region_depth > depth
+ ty.region_depth > depth
}
#[deriving(Clone, PartialEq, Eq, Hash, Show)]
}
fn add_ty(&mut self, ty: Ty) {
- let t_box = get(ty);
- self.add_flags(t_box.flags);
- self.add_depth(t_box.region_depth);
+ self.add_flags(ty.flags);
+ self.add_depth(ty.region_depth);
}
fn add_tys(&mut self, tys: &[Ty]) {
if !f(ty) {
return;
}
- match get(ty).sty {
+ match ty.sty {
ty_bool | ty_char | ty_int(_) | ty_uint(_) | ty_float(_) |
ty_str | ty_infer(_) | ty_param(_) | ty_err => {}
ty_uniq(ty) | ty_vec(ty, _) | ty_open(ty) => maybe_walk_ty(ty, f),
// Type utilities
pub fn type_is_nil(ty: Ty) -> bool {
- match get(ty).sty {
+ match ty.sty {
ty_tup(ref tys) => tys.is_empty(),
_ => false
}
}
pub fn type_is_error(ty: Ty) -> bool {
- get(ty).flags.intersects(HAS_TY_ERR)
+ ty.flags.intersects(HAS_TY_ERR)
}
pub fn type_needs_subst(ty: Ty) -> bool {
- tbox_has_flag(get(ty), NEEDS_SUBST)
+ ty.flags.intersects(NEEDS_SUBST)
}
pub fn trait_ref_contains_error(tref: &ty::TraitRef) -> bool {
}
pub fn type_is_ty_var(ty: Ty) -> bool {
- match get(ty).sty {
+ match ty.sty {
ty_infer(TyVar(_)) => true,
_ => false
}
}
-pub fn type_is_bool(ty: Ty) -> bool { get(ty).sty == ty_bool }
+pub fn type_is_bool(ty: Ty) -> bool { ty.sty == ty_bool }
pub fn type_is_self(ty: Ty) -> bool {
- match get(ty).sty {
+ match ty.sty {
ty_param(ref p) => p.space == subst::SelfSpace,
_ => false
}
}
fn type_is_slice(ty: Ty) -> bool {
- match get(ty).sty {
- ty_ptr(mt) | ty_rptr(_, mt) => match get(mt.ty).sty {
+ match ty.sty {
+ ty_ptr(mt) | ty_rptr(_, mt) => match mt.ty.sty {
ty_vec(_, None) | ty_str => true,
_ => false,
},
}
pub fn type_is_vec(ty: Ty) -> bool {
- match get(ty).sty {
+ match ty.sty {
ty_vec(..) => true,
ty_ptr(mt{ty, ..}) | ty_rptr(_, mt{ty, ..}) |
- ty_uniq(ty) => match get(ty).sty {
+ ty_uniq(ty) => match ty.sty {
ty_vec(_, None) => true,
_ => false
},
}
pub fn type_is_structural(ty: Ty) -> bool {
- match get(ty).sty {
+ match ty.sty {
ty_struct(..) | ty_tup(_) | ty_enum(..) | ty_closure(_) |
ty_vec(_, Some(_)) | ty_unboxed_closure(..) => true,
_ => type_is_slice(ty) | type_is_trait(ty)
}
pub fn type_is_simd(cx: &ctxt, ty: Ty) -> bool {
- match get(ty).sty {
+ match ty.sty {
ty_struct(did, _) => lookup_simd(cx, did),
_ => false
}
}
pub fn sequence_element_type<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx> {
- match get(ty).sty {
+ match ty.sty {
ty_vec(ty, _) => ty,
ty_str => mk_mach_uint(ast::TyU8),
ty_open(ty) => sequence_element_type(cx, ty),
}
pub fn simd_type<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx> {
- match get(ty).sty {
+ match ty.sty {
ty_struct(did, ref substs) => {
let fields = lookup_struct_fields(cx, did);
lookup_field_type(cx, did, fields[0].id, substs)
}
pub fn simd_size(cx: &ctxt, ty: Ty) -> uint {
- match get(ty).sty {
+ match ty.sty {
ty_struct(did, _) => {
let fields = lookup_struct_fields(cx, did);
fields.len()
}
pub fn type_is_region_ptr(ty: Ty) -> bool {
- match get(ty).sty {
+ match ty.sty {
ty_rptr(..) => true,
_ => false
}
}
pub fn type_is_unsafe_ptr(ty: Ty) -> bool {
- match get(ty).sty {
+ match ty.sty {
ty_ptr(_) => return true,
_ => return false
}
}
pub fn type_is_unique(ty: Ty) -> bool {
- match get(ty).sty {
- ty_uniq(_) => match get(ty).sty {
+ match ty.sty {
+ ty_uniq(_) => match ty.sty {
ty_trait(..) => false,
_ => true
},
}
pub fn type_is_fat_ptr<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> bool {
- match get(ty).sty {
+ match ty.sty {
ty_ptr(mt{ty, ..}) | ty_rptr(_, mt{ty, ..})
| ty_uniq(ty) if !type_is_sized(cx, ty) => true,
_ => false,
contents are abstract to rustc.)
*/
pub fn type_is_scalar(ty: Ty) -> bool {
- match get(ty).sty {
+ match ty.sty {
ty_bool | ty_char | ty_int(_) | ty_float(_) | ty_uint(_) |
ty_infer(IntVar(_)) | ty_infer(FloatVar(_)) |
ty_bare_fn(..) | ty_ptr(_) => true,
/// Returns true if this type is a floating point type and false otherwise.
pub fn type_is_floating_point(ty: Ty) -> bool {
- match get(ty).sty {
+ match ty.sty {
ty_float(_) => true,
_ => false,
}
let mut needs_unwind_cleanup = false;
maybe_walk_ty(ty, |ty| {
- needs_unwind_cleanup |= match get(ty).sty {
+ needs_unwind_cleanup |= match ty.sty {
ty_bool | ty_int(_) | ty_uint(_) |
ty_float(_) | ty_tup(_) | ty_ptr(_) => false,
}
cache.insert(ty, TC::None);
- let result = match get(ty).sty {
+ let result = match ty.sty {
// uint and int are ffi-unsafe
ty_uint(ast::TyU) | ty_int(ast::TyI) => {
TC::ReachesFfiUnsafe
}
ty_uniq(typ) => {
- TC::ReachesFfiUnsafe | match get(typ).sty {
+ TC::ReachesFfiUnsafe | match typ.sty {
ty_str => TC::OwnsOwned,
_ => tc_ty(cx, typ, cache).owned_pointer(),
}
}
ty_rptr(r, ref mt) => {
- TC::ReachesFfiUnsafe | match get(mt.ty).sty {
+ TC::ReachesFfiUnsafe | match mt.ty.sty {
ty_str => borrowed_contents(r, ast::MutImmutable),
ty_vec(..) => tc_ty(cx, mt.ty, cache).reference(borrowed_contents(r, mt.mutbl)),
_ => tc_ty(cx, mt.ty, cache).reference(borrowed_contents(r, mt.mutbl)),
}
if variants[data_idx].args.len() == 1 {
- match get(variants[data_idx].args[0]).sty {
+ match variants[data_idx].args[0].sty {
ty_bare_fn(..) => { res = res - TC::ReachesFfiUnsafe; }
_ => { }
}
::util::ppaux::ty_to_string(cx, r_ty),
::util::ppaux::ty_to_string(cx, ty));
- let r = {
- get(r_ty).sty == get(ty).sty ||
- subtypes_require(cx, seen, r_ty, ty)
- };
+ let r = r_ty == ty || subtypes_require(cx, seen, r_ty, ty);
debug!("type_requires({}, {})? {}",
::util::ppaux::ty_to_string(cx, r_ty),
::util::ppaux::ty_to_string(cx, r_ty),
::util::ppaux::ty_to_string(cx, ty));
- let r = match get(ty).sty {
+ let r = match ty.sty {
// fixed length vectors need special treatment compared to
// normal vectors, since they don't necessarily have the
// possibility to have length zero.
fn are_inner_types_recursive<'tcx>(cx: &ctxt<'tcx>, sp: Span,
seen: &mut Vec<Ty<'tcx>>, ty: Ty<'tcx>)
-> Representability {
- match get(ty).sty {
+ match ty.sty {
ty_tup(ref ts) => {
find_nonrepresentable(cx, sp, seen, ts.iter().map(|ty| *ty))
}
}
fn same_struct_or_enum_def_id(ty: Ty, did: DefId) -> bool {
- match get(ty).sty {
+ match ty.sty {
ty_struct(ty_did, _) | ty_enum(ty_did, _) => {
ty_did == did
}
}
fn same_type<'tcx>(a: Ty<'tcx>, b: Ty<'tcx>) -> bool {
- match (&get(a).sty, &get(b).sty) {
+ match (&a.sty, &b.sty) {
(&ty_struct(did_a, ref substs_a), &ty_struct(did_b, ref substs_b)) |
(&ty_enum(did_a, ref substs_a), &ty_enum(did_b, ref substs_b)) => {
if did_a != did_b {
debug!("is_type_structurally_recursive: {}",
::util::ppaux::ty_to_string(cx, ty));
- match get(ty).sty {
+ match ty.sty {
ty_struct(did, _) | ty_enum(did, _) => {
{
// Iterate through stack of previously seen types.
}
pub fn type_trait_info<'tcx>(ty: Ty<'tcx>) -> Option<&'tcx TyTrait<'tcx>> {
- match get(ty).sty {
- ty_uniq(ty) | ty_rptr(_, mt { ty, ..}) | ty_ptr(mt { ty, ..}) => match get(ty).sty {
+ match ty.sty {
+ ty_uniq(ty) | ty_rptr(_, mt { ty, ..}) | ty_ptr(mt { ty, ..}) => match ty.sty {
ty_trait(ref t) => Some(&**t),
_ => None
},
}
pub fn type_is_integral(ty: Ty) -> bool {
- match get(ty).sty {
+ match ty.sty {
ty_infer(IntVar(_)) | ty_int(_) | ty_uint(_) => true,
_ => false
}
}
pub fn type_is_skolemized(ty: Ty) -> bool {
- match get(ty).sty {
+ match ty.sty {
ty_infer(SkolemizedTy(_)) => true,
ty_infer(SkolemizedIntTy(_)) => true,
_ => false
}
pub fn type_is_uint(ty: Ty) -> bool {
- match get(ty).sty {
+ match ty.sty {
ty_infer(IntVar(_)) | ty_uint(ast::TyU) => true,
_ => false
}
}
pub fn type_is_char(ty: Ty) -> bool {
- match get(ty).sty {
+ match ty.sty {
ty_char => true,
_ => false
}
}
pub fn type_is_bare_fn(ty: Ty) -> bool {
- match get(ty).sty {
+ match ty.sty {
ty_bare_fn(..) => true,
_ => false
}
}
pub fn type_is_fp(ty: Ty) -> bool {
- match get(ty).sty {
+ match ty.sty {
ty_infer(FloatVar(_)) | ty_float(_) => true,
_ => false
}
}
pub fn type_is_signed(ty: Ty) -> bool {
- match get(ty).sty {
+ match ty.sty {
ty_int(_) => true,
_ => false
}
}
pub fn type_is_machine(ty: Ty) -> bool {
- match get(ty).sty {
+ match ty.sty {
ty_int(ast::TyI) | ty_uint(ast::TyU) => false,
ty_int(..) | ty_uint(..) | ty_float(..) => true,
_ => false
}
pub fn lltype_is_sized<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> bool {
- match get(ty).sty {
+ match ty.sty {
ty_open(_) => true,
_ => type_contents(cx, ty).is_sized(cx)
}
// 'Smallest' here means component of the static representation of the type; not
// the size of an object at runtime.
pub fn unsized_part_of_type<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx> {
- match get(ty).sty {
+ match ty.sty {
ty_str | ty_trait(..) | ty_vec(..) => ty,
ty_struct(def_id, ref substs) => {
let unsized_fields: Vec<_> = struct_fields(cx, def_id, substs).iter()
// Whether a type is enum like, that is an enum type with only nullary
// constructors
pub fn type_is_c_like_enum(cx: &ctxt, ty: Ty) -> bool {
- match get(ty).sty {
+ match ty.sty {
ty_enum(did, _) => {
let variants = enum_variants(cx, did);
if variants.len() == 0 {
// The parameter `explicit` indicates if this is an *explicit* dereference.
// Some types---notably unsafe ptrs---can only be dereferenced explicitly.
pub fn deref<'tcx>(ty: Ty<'tcx>, explicit: bool) -> Option<mt<'tcx>> {
- match get(ty).sty {
+ match ty.sty {
ty_uniq(ty) => {
Some(mt {
ty: ty,
}
pub fn deref_or_dont<'tcx>(ty: Ty<'tcx>) -> Ty<'tcx> {
- match get(ty).sty {
+ match ty.sty {
ty_uniq(ty) => ty,
ty_rptr(_, mt) | ty_ptr(mt) => mt.ty,
_ => ty
}
pub fn close_type<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx> {
- match get(ty).sty {
+ match ty.sty {
ty_open(ty) => mk_rptr(cx, ReStatic, mt {ty: ty, mutbl:ast::MutImmutable}),
_ => cx.sess.bug(format!("Trying to close a non-open type {}",
ty_to_string(cx, ty)).as_slice())
}
pub fn type_content<'tcx>(ty: Ty<'tcx>) -> Ty<'tcx> {
- match get(ty).sty {
+ match ty.sty {
ty_uniq(ty) => ty,
ty_rptr(_, mt) |ty_ptr(mt) => mt.ty,
_ => ty
// Extract the unsized type in an open type (or just return ty if it is not open).
pub fn unopen_type<'tcx>(ty: Ty<'tcx>) -> Ty<'tcx> {
- match get(ty).sty {
+ match ty.sty {
ty_open(ty) => ty,
_ => ty
}
// Returns the type of ty[i]
pub fn index<'tcx>(ty: Ty<'tcx>) -> Option<Ty<'tcx>> {
- match get(ty).sty {
+ match ty.sty {
ty_vec(ty, _) => Some(ty),
_ => None
}
// This is exactly the same as the above, except it supports strings,
// which can't actually be indexed.
pub fn array_element_ty<'tcx>(ty: Ty<'tcx>) -> Option<Ty<'tcx>> {
- match get(ty).sty {
+ match ty.sty {
ty_vec(ty, _) => Some(ty),
ty_str => Some(mk_u8()),
_ => None
}
pub fn fn_is_variadic(fty: Ty) -> bool {
- match get(fty).sty {
+ match fty.sty {
ty_bare_fn(ref f) => f.sig.variadic,
ty_closure(ref f) => f.sig.variadic,
ref s => {
}
pub fn ty_fn_sig<'tcx>(fty: Ty<'tcx>) -> &'tcx FnSig<'tcx> {
- match get(fty).sty {
+ match fty.sty {
ty_bare_fn(ref f) => &f.sig,
ty_closure(ref f) => &f.sig,
ref s => {
/// Returns the ABI of the given function.
pub fn ty_fn_abi(fty: Ty) -> abi::Abi {
- match get(fty).sty {
+ match fty.sty {
ty_bare_fn(ref f) => f.abi,
ty_closure(ref f) => f.abi,
_ => panic!("ty_fn_abi() called on non-fn type"),
}
pub fn ty_closure_store(fty: Ty) -> TraitStore {
- match get(fty).sty {
+ match fty.sty {
ty_closure(ref f) => f.store,
ty_unboxed_closure(..) => {
// Close enough for the purposes of all the callers of this
}
pub fn ty_fn_ret<'tcx>(fty: Ty<'tcx>) -> FnOutput<'tcx> {
- match get(fty).sty {
+ match fty.sty {
ty_bare_fn(ref f) => f.sig.output,
ty_closure(ref f) => f.sig.output,
ref s => {
}
pub fn is_fn_ty(fty: Ty) -> bool {
- match get(fty).sty {
+ match fty.sty {
ty_bare_fn(_) => true,
ty_closure(_) => true,
_ => false
pub fn ty_region(tcx: &ctxt,
span: Span,
ty: Ty) -> Region {
- match get(ty).sty {
+ match ty.sty {
ty_rptr(r, _) => r,
ref s => {
tcx.sess.span_bug(
-> Ty<'tcx> {
/*! See `expr_ty_adjusted` */
- match get(unadjusted_ty).sty {
+ match unadjusted_ty.sty {
ty_err => return unadjusted_ty,
_ => {}
}
Some(adjustment) => {
match *adjustment {
AdjustAddEnv(store) => {
- match ty::get(unadjusted_ty).sty {
+ match unadjusted_ty.sty {
ty::ty_bare_fn(ref b) => {
let bounds = ty::ExistentialBounds {
region_bound: ReStatic,
span: Span)
-> Ty<'tcx> {
match kind {
- &UnsizeLength(len) => match get(ty).sty {
+ &UnsizeLength(len) => match ty.sty {
ty_vec(ty, Some(n)) => {
assert!(len == n);
mk_vec(cx, ty, None)
format!("UnsizeLength with bad sty: {}",
ty_to_string(cx, ty)).as_slice())
},
- &UnsizeStruct(box ref k, tp_index) => match get(ty).sty {
+ &UnsizeStruct(box ref k, tp_index) => match ty.sty {
ty_struct(did, ref substs) => {
let ty_substs = substs.types.get_slice(subst::TypeSpace);
let new_ty = unsize_ty(cx, ty_substs[tp_index], k, span);
}
def::DefStruct(_) => {
- match get(expr_ty(tcx, expr)).sty {
+ match expr_ty(tcx, expr).sty {
ty_bare_fn(..) => RvalueDatumExpr,
_ => RvalueDpsExpr
}
}
pub fn ty_sort_string<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> String {
- match get(ty).sty {
+ match ty.sty {
ty_bool | ty_char | ty_int(_) |
ty_uint(_) | ty_float(_) | ty_str => {
::util::ppaux::ty_to_string(cx, ty)
}
pub fn ty_to_def_id(ty: Ty) -> Option<ast::DefId> {
- match get(ty).sty {
+ match ty.sty {
ty_trait(ref tt) =>
Some(tt.principal.def_id),
ty_struct(id, _) |
}
pub fn type_is_empty(cx: &ctxt, ty: Ty) -> bool {
- match ty::get(ty).sty {
+ match ty.sty {
ty_enum(did, _) => (*enum_variants(cx, did)).is_empty(),
_ => false
}
if type_is_simd(cx, ty) {
return tycat(cx, simd_type(cx, ty))
}
- match get(ty).sty {
+ match ty.sty {
ty_char => tycat_char,
ty_bool => tycat_bool,
ty_int(_) | ty_uint(_) | ty_infer(IntVar(_)) => tycat_int,
mt.mutbl.hash(state);
};
ty::walk_ty(ty, |ty| {
- match ty::get(ty).sty {
+ match ty.sty {
ty_bool => byte!(2),
ty_char => byte!(3),
ty_int(i) => {
pub fn accumulate_lifetimes_in_type(accumulator: &mut Vec<ty::Region>,
ty: Ty) {
walk_ty(ty, |ty| {
- match get(ty).sty {
+ match ty.sty {
ty_rptr(region, _) => {
accumulator.push(region)
}
pub fn super_fold_ty<'tcx, T: TypeFolder<'tcx>>(this: &mut T,
t: Ty<'tcx>)
-> Ty<'tcx> {
- let sty = ty::get(t).sty.fold_with(this);
+ let sty = t.sty.fold_with(this);
ty::mk_t(this.tcx(), sty)
}
def::DefTy(did, _) |
def::DefStruct(did) if Some(did) == this.tcx().lang_items.owned_box() => {
let ty = ast_path_to_ty(this, rscope, did, path).ty;
- match ty::get(ty).sty {
+ match ty.sty {
ty::ty_struct(struct_def_id, ref substs) => {
assert_eq!(struct_def_id, did);
assert_eq!(substs.types.len(TypeSpace), 1);
if impl_modifiers >= method_modifiers {
ty::ByValueExplicitSelfCategory
} else {
- match ty::get(explicit_type).sty {
+ match explicit_type.sty {
ty::ty_rptr(r, mt) => ty::ByReferenceExplicitSelfCategory(r, mt.mutbl),
ty::ty_uniq(_) => ty::ByBoxExplicitSelfCategory,
_ => ty::ByValueExplicitSelfCategory,
};
fn count_modifiers(ty: Ty) -> uint {
- match ty::get(ty).sty {
+ match ty.sty {
ty::ty_rptr(_, mt) => count_modifiers(mt.ty) + 1,
ty::ty_uniq(t) => count_modifiers(t) + 1,
_ => 0,
ast::PatVec(ref before, ref slice, ref after) => {
let expected_ty = structurally_resolved_type(fcx, pat.span, expected);
let inner_ty = fcx.infcx().next_ty_var();
- let pat_ty = match ty::get(expected_ty).sty {
+ let pat_ty = match expected_ty.sty {
ty::ty_vec(_, Some(size)) => ty::mk_vec(tcx, inner_ty, Some({
let min_len = before.len() + after.len();
match *slice {
fcx.infcx(), Some(span),
expected, resolve::try_resolve_tvar_shallow) {
Ok(t) if pat_is_binding(&tcx.def_map, inner) => {
- ty::deref(t, true).map_or(true, |mt| match ty::get(mt.ty).sty {
+ ty::deref(t, true).map_or(true, |mt| match mt.ty.sty {
ty::ty_trait(_) => {
// This is "x = SomeTrait" being reduced from
// "let &x = &SomeTrait" or "let box x = Box<SomeTrait>", an error.
},
_ => {
let def_type = ty::lookup_item_type(tcx, def.def_id());
- match ty::get(def_type.ty).sty {
+ match def_type.ty.sty {
ty::ty_struct(struct_def_id, _) =>
(struct_def_id, struct_def_id),
ty::ty_enum(enum_def_id, _)
demand::eqtype(fcx, pat.span, expected, pat_ty);
let real_path_ty = fcx.node_ty(pat.id);
- let (arg_tys, kind_name) = match ty::get(real_path_ty).sty {
+ let (arg_tys, kind_name) = match real_path_ty.sty {
ty::ty_enum(enum_def_id, ref expected_substs) => {
let variant = ty::enum_variant_with_id(tcx, enum_def_id, def.def_id());
(variant.args.iter().map(|t| t.subst(tcx, expected_substs)).collect::<Vec<_>>(),
check::autoderef(
self.fcx, self.span, self_ty, None, NoPreference,
|ty, _| {
- match ty::get(ty).sty {
+ match ty.sty {
ty::ty_trait(ref data) => Some(closure(self, ty, &**data)),
_ => None,
}
* `DerefMut` and `IndexMut` respectively.
*/
- let sig = match ty::get(method_callee.ty).sty {
+ let sig = match method_callee.ty.sty {
ty::ty_bare_fn(ref f) => f.sig.clone(),
ty::ty_closure(ref f) => f.sig.clone(),
_ => return,
};
- match ty::get(sig.inputs[0]).sty {
+ match sig.inputs[0].sty {
ty::ty_rptr(_, ty::mt {
ty: _,
mutbl: ast::MutMutable,
ty::ByReferenceExplicitSelfCategory(..) => {
// Trait method is fn(&self) or fn(&mut self), need an
// autoref. Pull the region etc out of the type of first argument.
- match ty::get(transformed_self_ty).sty {
+ match transformed_self_ty.sty {
ty::ty_rptr(region, ty::mt { mutbl, ty: _ }) => {
let ty::AutoDerefRef { autoderefs, autoref } = autoderefref;
let autoref = autoref.map(|r| box r);
// True if the type is a struct and contains a field with
// the same name as the not-found method
- let is_field = match ty::get(rcvr_ty).sty {
+ let is_field = match rcvr_ty.sty {
ty_struct(did, _) =>
ty::lookup_struct_fields(cx, did)
.iter()
None::<()> // keep iterating until we can't anymore
});
- match ty::get(fully_dereferenced_ty).sty {
+ match fully_dereferenced_ty.sty {
ty::ty_vec(elem_ty, Some(len)) => {
steps.push(CandidateStep {
self_ty: ty::mk_vec(fcx.tcx(), elem_ty, None),
return steps;
- fn consider_reborrow(t: Ty, d: uint) -> PickAdjustment {
+ fn consider_reborrow(ty: Ty, d: uint) -> PickAdjustment {
// Insert a `&*` or `&mut *` if this is a reference type:
- match ty::get(t).sty {
+ match ty.sty {
ty::ty_rptr(_, ref mt) => AutoRef(mt.mutbl, box AutoDeref(d+1)),
_ => AutoDeref(d),
}
debug!("assemble_probe: self_ty={}",
self_ty.repr(self.tcx()));
- match ty::get(self_ty).sty {
+ match self_ty.sty {
ty::ty_trait(box ty::TyTrait { ref principal, bounds, .. }) => {
self.assemble_inherent_candidates_from_object(self_ty, &*principal, bounds);
self.assemble_inherent_impl_candidates_for_type(principal.def_id);
// If so, add "synthetic impls".
let steps = self.steps.clone();
for step in steps.iter() {
- let (closure_def_id, _, _) = match ty::get(step.self_ty).sty {
+ let (closure_def_id, _, _) = match step.self_ty.sty {
ty::ty_unboxed_closure(a, b, ref c) => (a, b, c),
_ => continue,
};
// FIXME -- Super hack. For DST types, we will convert to
// &&[T] or &&str, as part of a kind of legacy lookup scheme.
- match ty::get(step.self_ty).sty {
+ match step.self_ty.sty {
ty::ty_str | ty::ty_vec(_, None) => self.pick_autorefrefd_method(step),
_ => None
}
// (replace any type-scheme with a type)
let fty = fty.subst(ccx.tcx, ¶m_env.free_substs);
- match ty::get(fty).sty {
+ match fty.sty {
ty::ty_bare_fn(ref fn_ty) => {
let inh = Inherited::new(ccx.tcx, param_env);
let fcx = check_fn(ccx, fn_ty.fn_style, id, &fn_ty.sig,
fcx.type_error_message(span, |actual| {
format!("cast to unsized type: `{}` as `{}`", actual, tstr)
}, t_e, None);
- match ty::get(t_e).sty {
+ match t_e.sty {
ty::ty_rptr(_, ty::mt { mutbl: mt, .. }) => {
let mtstr = match mt {
ast::MutMutable => "mut ",
// casts from C-like enums are allowed
} else if t_1_is_char {
let t_e = fcx.infcx().shallow_resolve(t_e);
- if ty::get(t_e).sty != ty::ty_uint(ast::TyU8) {
+ if t_e.sty != ty::ty_uint(ast::TyU8) {
fcx.type_error_message(span, |actual| {
format!("only `u8` can be cast as \
`char`, not `{}`", actual)
}, t_e, None);
}
- } else if ty::get(t_1).sty == ty::ty_bool {
+ } else if t_1.sty == ty::ty_bool {
span_err!(fcx.tcx().sess, span, E0054,
"cannot cast as `bool`, compare with zero instead");
} else if ty::type_is_region_ptr(t_e) && ty::type_is_unsafe_ptr(t_1) {
fn types_compatible<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, sp: Span,
t1: Ty<'tcx>, t2: Ty<'tcx>) -> bool {
- match ty::get(t1).sty {
+ match t1.sty {
ty::ty_vec(_, Some(_)) => {}
_ => return false
}
/* this cast is only allowed from &[T, ..n] to *T or
&T to *T. */
- match (&ty::get(t_e).sty, &ty::get(t_1).sty) {
+ match (&t_e.sty, &t_1.sty) {
(&ty::ty_rptr(_, ty::mt { ty: mt1, mutbl: ast::MutImmutable }),
&ty::ty_ptr(ty::mt { ty: mt2, mutbl: ast::MutImmutable }))
if types_compatible(fcx, e.span, mt1, mt2) => {
// After we have fully autoderef'd, if the resulting type is [T, ..n], then
// do a final unsized coercion to yield [T].
- match ty::get(ty).sty {
+ match ty.sty {
ty::ty_vec(element_ty, Some(n)) => {
let adjusted_ty = ty::mk_vec(fcx.tcx(), element_ty, None);
let autoderefref = ty::AutoDerefRef {
structurally_resolved_type(fcx, iterator_expr.span, return_type),
ty::FnDiverging => ty::mk_err()
};
- match ty::get(return_type).sty {
+ match return_type.sty {
ty::ty_enum(_, ref substs)
if !substs.types.is_empty_in(subst::TypeSpace) => {
*substs.types.get(subst::TypeSpace, 0)
tuple_arguments);
ty::FnConverging(ty::mk_err())
} else {
- match ty::get(method_fn_ty).sty {
+ match method_fn_ty.sty {
ty::ty_bare_fn(ref fty) => {
// HACK(eddyb) ignore self in the definition (see above).
check_argument_types(fcx,
let expected_arg_count = fn_inputs.len();
let formal_tys = if tuple_arguments == TupleArguments {
let tuple_type = structurally_resolved_type(fcx, sp, fn_inputs[0]);
- match ty::get(tuple_type).sty {
+ match tuple_type.sty {
ty::ty_tup(ref arg_types) => {
if arg_types.len() != args.len() {
span_err!(tcx.sess, sp, E0057,
match deref_args {
DoDerefArgs => {
- match ty::get(formal_ty).sty {
+ match formal_ty.sty {
ty::ty_rptr(_, mt) => formal_ty = mt.ty,
ty::ty_err => (),
_ => {
// in C but we just error out instead and require explicit casts.
let arg_ty = structurally_resolved_type(fcx, arg.span,
fcx.expr_ty(&***arg));
- match ty::get(arg_ty).sty {
+ match arg_ty.sty {
ty::ty_float(ast::TyF32) => {
fcx.type_error_message(arg.span,
|t| {
// could also solve this with variance or different
// traits that don't force left and right to have same
// type.
- let (adj_ty, adjustment) = match ty::get(lhs_ty).sty {
+ let (adj_ty, adjustment) = match lhs_ty.sty {
ty::ty_rptr(r_in, mt) => {
let r_adj = fcx.infcx().next_region_var(infer::Autoref(lhs.span));
fcx.mk_subr(infer::Reborrow(lhs.span), r_adj, r_in);
// FIXME(eddyb) #12808 Integrate privacy into this auto-deref loop.
let (_, autoderefs, field_ty) =
autoderef(fcx, expr.span, expr_t, Some(base.id), lvalue_pref, |base_t, _| {
- match ty::get(base_t).sty {
+ match base_t.sty {
ty::ty_struct(base_id, ref substs) => {
debug!("struct named {}", ppaux::ty_to_string(tcx, base_t));
let fields = ty::lookup_struct_fields(tcx, base_id);
// FIXME(eddyb) #12808 Integrate privacy into this auto-deref loop.
let (_, autoderefs, field_ty) =
autoderef(fcx, expr.span, expr_t, Some(base.id), lvalue_pref, |base_t, _| {
- match ty::get(base_t).sty {
+ match base_t.sty {
ty::ty_struct(base_id, ref substs) => {
tuple_like = ty::is_tuple_struct(tcx, base_id);
if tuple_like {
Some(&**oprnd), oprnd_t, lvalue_pref) {
Some(mt) => mt.ty,
None => {
- let is_newtype = match ty::get(oprnd_t).sty {
+ let is_newtype = match oprnd_t.sty {
ty::ty_struct(did, ref substs) => {
let fields = ty::struct_fields(fcx.tcx(), did, substs);
fields.len() == 1
oprnd_t = structurally_resolved_type(fcx, oprnd.span,
oprnd_t);
if !(ty::type_is_integral(oprnd_t) ||
- ty::get(oprnd_t).sty == ty::ty_bool) {
+ oprnd_t.sty == ty::ty_bool) {
oprnd_t = check_user_unop(fcx, "!", "not",
tcx.lang_items.not_trait(),
expr, &**oprnd, oprnd_t);
ast::ExprVec(ref args) => {
let uty = match expected {
ExpectHasType(uty) => {
- match ty::get(uty).sty {
+ match uty.sty {
ty::ty_vec(ty, _) => Some(ty),
_ => None
}
let uty = match expected {
ExpectHasType(uty) => {
- match ty::get(uty).sty {
+ match uty.sty {
ty::ty_vec(ty, _) => Some(ty),
_ => None
}
Some(def) => {
// Verify that this was actually a struct.
let typ = ty::lookup_item_type(fcx.ccx.tcx, def.def_id());
- match ty::get(typ.ty).sty {
+ match typ.ty.sty {
ty::ty_struct(struct_did, _) => {
check_struct_constructor(fcx,
id,
-> Expectation<'tcx> {
match self.resolve(fcx) {
NoExpectation => NoExpectation,
- ExpectCastableToType(t) | ExpectHasType(t) => unpack(&ty::get(t).sty),
+ ExpectCastableToType(t) | ExpectHasType(t) => unpack(&t.sty),
}
}
{
match self.resolve(fcx) {
NoExpectation => None,
- ExpectCastableToType(t) | ExpectHasType(t) => unpack(&ty::get(t).sty),
+ ExpectCastableToType(t) | ExpectHasType(t) => unpack(&t.sty),
}
}
}
span_err!(tcx.sess, sp, E0074, "SIMD vector cannot be generic");
return;
}
- match ty::get(t).sty {
+ match t.sty {
ty::ty_struct(did, ref substs) => {
let fields = ty::lookup_struct_fields(tcx, did);
if fields.is_empty() {
// Returns the one-level-deep structure of the given type.
pub fn structure_of<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, sp: Span, typ: Ty<'tcx>)
-> &'tcx ty::sty<'tcx> {
- &ty::get(structurally_resolved_type(fcx, sp, typ)).sty
+ &structurally_resolved_type(fcx, sp, typ).sty
}
// Returns true if b contains a break that can exit from b
let mut tps_used = Vec::from_elem(tps.len(), false);
ty::walk_ty(ty, |t| {
- match ty::get(t).sty {
+ match t.sty {
ty::ty_param(ParamTy {idx, ..}) => {
debug!("Found use of ty param num {}", idx);
tps_used[idx] = true;
}
None => rcx.resolve_node_type(base.id)
};
- match ty::get(base_ty).sty {
+ match base_ty.sty {
ty::ty_rptr(r_ptr, _) => {
mk_subregion_due_to_dereference(rcx, expr.span,
ty::ReScope(expr.id), r_ptr);
debug!("walk_cast(from_ty={}, to_ty={})",
from_ty.repr(rcx.tcx()),
to_ty.repr(rcx.tcx()));
- match (&ty::get(from_ty).sty, &ty::get(to_ty).sty) {
+ match (&from_ty.sty, &to_ty.sty) {
/*From:*/ (&ty::ty_rptr(from_r, ref from_mt),
/*To: */ &ty::ty_rptr(to_r, ref to_mt)) => {
// Target cannot outlive source, naturally.
let tcx = rcx.fcx.tcx();
let function_type = rcx.resolve_node_type(expr.id);
- match ty::get(function_type).sty {
+ match function_type.sty {
ty::ty_closure(box ty::ClosureTy{store: ty::RegionTraitStore(..),
ref bounds,
..}) => {
visit::walk_expr(rcx, expr);
rcx.set_repeating_scope(repeating_scope);
- match ty::get(function_type).sty {
+ match function_type.sty {
ty::ty_closure(box ty::ClosureTy { store: ty::RegionTraitStore(..), .. }) => {
ty::with_freevars(tcx, expr.id, |freevars| {
propagate_upupvar_borrow_kind(rcx, expr, freevars);
_ => {}
}
- match ty::get(function_type).sty {
+ match function_type.sty {
ty::ty_closure(box ty::ClosureTy {bounds, ..}) => {
ty::with_freevars(tcx, expr.id, |freevars| {
ensure_free_variable_types_outlive_closure_bound(rcx, bounds, expr, freevars);
let call_region = ty::ReScope(call_expr.id);
let callee_ty = rcx.resolve_node_type(callee_id);
- match ty::get(callee_ty).sty {
+ match callee_ty.sty {
ty::ty_bare_fn(..) => { }
ty::ty_closure(ref closure_ty) => {
let region = match closure_ty.store {
// was applied on the base type, as that is always the case.
let fn_sig = ty::ty_fn_sig(method.ty);
let self_ty = fn_sig.inputs[0];
- let (m, r) = match ty::get(self_ty).sty {
+ let (m, r) = match self_ty.sty {
ty::ty_rptr(r, ref m) => (m.mutbl, r),
_ => rcx.tcx().sess.span_bug(deref_expr.span,
format!("bad overloaded deref type {}",
None => derefd_ty
};
- match ty::get(derefd_ty).sty {
+ match derefd_ty.sty {
ty::ty_rptr(r_ptr, _) => {
mk_subregion_due_to_dereference(rcx, deref_expr.span,
r_deref_expr, r_ptr);
rcx.fcx.infcx().ty_to_string(indexed_ty));
let r_index_expr = ty::ReScope(index_expr.id);
- match ty::get(indexed_ty).sty {
- ty::ty_rptr(r_ptr, mt) => match ty::get(mt.ty).sty {
+ match indexed_ty.sty {
+ ty::ty_rptr(r_ptr, mt) => match mt.ty.sty {
ty::ty_vec(_, None) | ty::ty_str => {
rcx.fcx.mk_subr(infer::IndexSlice(index_expr.span),
r_index_expr, r_ptr);
debug!("Wf::accumulate_from_ty(ty={})",
ty.repr(self.tcx));
- match ty::get(ty).sty {
+ match ty.sty {
ty::ty_bool |
ty::ty_char |
ty::ty_int(..) |
let source_ty = fcx.expr_ty(source_expr);
let source_ty = structurally_resolved_type(fcx, source_expr.span, source_ty);
debug!("source_ty={}", source_ty.repr(fcx.tcx()));
- match (&ty::get(source_ty).sty, &ty::get(target_object_ty).sty) {
+ match (&source_ty.sty, &target_object_ty.sty) {
(&ty::ty_uniq(referent_ty), &ty::ty_uniq(object_trait_ty)) => {
let object_trait = object_trait(&object_trait_ty);
}
fn object_trait<'a, 'tcx>(t: &'a Ty<'tcx>) -> &'a ty::TyTrait<'tcx> {
- match ty::get(*t).sty {
+ match t.sty {
ty::ty_trait(ref ty_trait) => &**ty_trait,
_ => panic!("expected ty_trait")
}
fcx.tcx().lang_items.drop_trait() == Some(trait_ref.def_id) &&
!attr::contains_name(item.attrs.as_slice(), "unsafe_destructor")
{
- match ty::get(self_ty).sty {
+ match self_ty.sty {
ty::ty_struct(def_id, _) |
ty::ty_enum(def_id, _) => {
check_struct_safe_for_destructor(fcx, item.span, self_ty, def_id);
None => { }
}
- match ty::get(t).sty{
+ match t.sty{
ty::ty_struct(type_id, ref substs) |
ty::ty_enum(type_id, ref substs) => {
let polytype = ty::lookup_item_type(self.fcx.tcx(), type_id);
use metadata::csearch;
use middle::subst;
use middle::subst::{Substs};
-use middle::ty::get;
use middle::ty::{ImplContainer, ImplOrTraitItemId, MethodTraitItemId};
use middle::ty::{TypeTraitItemId, lookup_item_type};
use middle::ty::{Ty, ty_bool, ty_char, ty_enum, ty_err};
}
};
- match get(resolved_type).sty {
+ match resolved_type.sty {
ty_enum(..) | ty_struct(..) | ty_unboxed_closure(..) => {
debug!("(getting base type) found base type");
Some(resolved_type)
ty_infer(..) | ty_param(..) | ty_err | ty_open(..) | ty_uniq(_) |
ty_ptr(_) | ty_rptr(_, _) => {
debug!("(getting base type) no base type; found {}",
- get(original_type).sty);
+ original_type.sty);
None
}
ty_trait(..) => panic!("should have been caught")
match get_base_type(inference_context, span, original_type) {
None => None,
Some(base_type) => {
- match get(base_type).sty {
+ match base_type.sty {
ty_enum(def_id, _) |
ty_struct(def_id, _) |
ty_unboxed_closure(def_id, _, _) => {
ty_ptr(ty::mt {ty, ..}) |
ty_rptr(_, ty::mt {ty, ..}) |
ty_uniq(ty) => {
- match ty::get(ty).sty {
+ match ty.sty {
ty_trait(box ty::TyTrait { ref principal, .. }) => {
Some(principal.def_id)
}
let method_def_id = items[0];
let self_type = self.get_self_type_for_implementation(impl_did);
- match ty::get(self_type.ty).sty {
+ match self_type.ty.sty {
ty::ty_enum(type_def_id, _) |
ty::ty_struct(type_def_id, _) |
ty::ty_unboxed_closure(type_def_id, _, _) => {
// defined in this crate.
debug!("coherence2::orphan check: inherent impl {}", item.repr(self.tcx));
let self_ty = ty::lookup_item_type(self.tcx, def_id).ty;
- match ty::get(self_ty).sty {
+ match self_ty.sty {
ty::ty_enum(def_id, _) |
ty::ty_struct(def_id, _) => {
self.check_def_id(item.span, def_id);
trait_id: ast::DefId,
generics: &ty::Generics)
-> bool {
- match ty::get(ty).sty {
+ match ty.sty {
ty::ty_param(param_ty) => {
let type_parameter = generics.types.get(param_ty.space,
param_ty.idx);
Some(ty) => ty,
};
- match ty::get(ty).sty {
+ match ty.sty {
ty::ty_param(ref param_ty) => {
/*let type_parameter = generics.types.get(param_ty.space,
param_ty.idx);
}
fn type_is_self(ty: Ty) -> bool {
- match ty::get(ty).sty {
+ match ty.sty {
ty::ty_param(ref param_ty) if param_ty.is_self() => true,
_ => false,
}
let cur_idx = index;
ty::walk_ty(ty, |t| {
- match ty::get(t).sty {
+ match t.sty {
ty::ty_param(p) => if p.idx > cur_idx {
span_err!(this.tcx().sess, path.span, E0128,
"type parameters with a default cannot use \
match explicit_self.node {
ast::SelfExplicit(ref ast_type, _) => {
let typ = crate_context.to_ty(rs, &**ast_type);
- let base_type = match ty::get(typ).sty {
+ let base_type = match typ.sty {
ty::ty_ptr(tm) | ty::ty_rptr(_, tm) => tm.ty,
ty::ty_uniq(typ) => typ,
_ => typ,
//
// Note: does not attempt to resolve type variables we encounter.
// See above for details.
- match ty::get(b).sty {
+ match b.sty {
ty::ty_ptr(mt_b) => {
- match ty::get(mt_b.ty).sty {
+ match mt_b.ty.sty {
ty::ty_str => {
return self.unpack_actual_value(a, |sty_a| {
self.coerce_unsafe_ptr(a, sty_a, b, ast::MutImmutable)
}
ty::ty_rptr(_, mt_b) => {
- match ty::get(mt_b.ty).sty {
+ match mt_b.ty.sty {
ty::ty_str => {
return self.unpack_actual_value(a, |sty_a| {
self.coerce_borrowed_pointer(a, sty_a, b, ast::MutImmutable)
match resolve_type(self.get_ref().infcx, None,
a, try_resolve_tvar_shallow) {
Ok(t) => {
- f(&ty::get(t).sty)
+ f(&t.sty)
}
Err(e) => {
self.get_ref().infcx.tcx.sess.span_bug(
let sub = Sub(self.get_ref().clone());
- let sty_b = &ty::get(b).sty;
+ let sty_b = &b.sty;
match (sty_a, sty_b) {
(&ty::ty_rptr(_, ty::mt{ty: t_a, mutbl: mutbl_a}), &ty::ty_rptr(_, mt_b)) => {
self.unpack_actual_value(t_a, |sty_a| {
let tcx = self.get_ref().infcx.tcx;
match *sty_a {
- ty::ty_rptr(_, ty::mt{ty, mutbl}) => match ty::get(ty).sty {
+ ty::ty_rptr(_, ty::mt{ty, mutbl}) => match ty.sty {
ty::ty_trait(box ty::TyTrait { ref principal, bounds }) => {
debug!("mutbl={} b_mutbl={}", mutbl, b_mutbl);
// FIXME what is purpose of this type `tr`?
-> cres<'tcx, Ty<'tcx>> {
let tcx = this.infcx().tcx;
- let a_sty = &ty::get(a).sty;
- let b_sty = &ty::get(b).sty;
+ let a_sty = &a.sty;
+ let b_sty = &b.sty;
debug!("super_tys: a_sty={} b_sty={}", a_sty, b_sty);
return match (a_sty, b_sty) {
// The "subtype" ought to be handling cases involving var:
(&ty::ty_int(_), _) |
(&ty::ty_uint(_), _) |
(&ty::ty_float(_), _) => {
- if ty::get(a).sty == ty::get(b).sty {
+ if a == b {
Ok(a)
} else {
Err(ty::terr_sorts(expected_found(this, a, b)))
// used to use covariant subtyping. I have preserved this behaviour,
// even though it is probably incorrect. So don't go down the usual
// path which would require invariance.
- let mt = match (&ty::get(a_mt.ty).sty, &ty::get(b_mt.ty).sty) {
+ let mt = match (&a_mt.ty.sty, &b_mt.ty.sty) {
(&ty::ty_trait(..), &ty::ty_trait(..)) if a_mt.mutbl == b_mt.mutbl => {
let ty = try!(this.tys(a_mt.ty, b_mt.ty));
ty::mt { ty: ty, mutbl: a_mt.mutbl }
//
// (In particular, you could have something like `$0 = Box<$1>`
// where `$1` has already been instantiated with `Box<$0>`)
- match ty::get(t).sty {
+ match t.sty {
ty::ty_infer(ty::TyVar(vid)) => {
if vid == self.for_vid {
self.cycle_detected = true;
let infcx = self.fields.infcx;
let a = infcx.type_variables.borrow().replace_if_possible(a);
let b = infcx.type_variables.borrow().replace_if_possible(b);
- match (&ty::get(a).sty, &ty::get(b).sty) {
+ match (&a.sty, &b.sty) {
(&ty::ty_infer(TyVar(a_id)), &ty::ty_infer(TyVar(b_id))) => {
infcx.type_variables.borrow_mut().relate_vars(a_id, EqTo, b_id);
Ok(a)
let infcx = this.infcx();
let a = infcx.type_variables.borrow().replace_if_possible(a);
let b = infcx.type_variables.borrow().replace_if_possible(b);
- match (&ty::get(a).sty, &ty::get(b).sty) {
+ match (&a.sty, &b.sty) {
(&ty::ty_infer(TyVar(..)), &ty::ty_infer(TyVar(..)))
if infcx.type_var_diverges(a) && infcx.type_var_diverges(b) => {
let v = infcx.next_diverging_ty_var();
}
pub fn type_var_diverges(&'a self, ty: Ty) -> bool {
- match ty::get(ty).sty {
+ match ty.sty {
ty::ty_infer(ty::TyVar(vid)) => self.type_variables.borrow().var_diverges(vid),
_ => false
}
}
pub fn shallow_resolve(&self, typ: Ty<'tcx>) -> Ty<'tcx> {
- match ty::get(typ).sty {
+ match typ.sty {
ty::ty_infer(ty::TyVar(v)) => {
self.type_variables.borrow()
.probe(v)
(*trait_ref).clone(),
ty::region_existential_bound(ty::ReStatic));
let dummy1 = self.resolve_type_vars_if_possible(dummy0);
- match ty::get(dummy1).sty {
+ match dummy1.sty {
ty::ty_trait(box ty::TyTrait { ref principal, .. }) => {
(*principal).clone()
}
return typ;
}
- match ty::get(typ).sty {
+ match typ.sty {
ty::ty_infer(TyVar(vid)) => {
self.resolve_ty_var(vid)
}
}
fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> {
- match ty::get(t).sty {
+ match t.sty {
ty::ty_infer(ty::TyVar(v)) => {
self.skolemize(self.infcx.type_variables.borrow().probe(v),
ty::TyVar(v),
let infcx = self.fields.infcx;
let a = infcx.type_variables.borrow().replace_if_possible(a);
let b = infcx.type_variables.borrow().replace_if_possible(b);
- match (&ty::get(a).sty, &ty::get(b).sty) {
+ match (&a.sty, &b.sty) {
(&ty::ty_infer(TyVar(a_id)), &ty::ty_infer(TyVar(b_id))) => {
infcx.type_variables
.borrow_mut()
}
pub fn replace_if_possible(&self, t: Ty<'tcx>) -> Ty<'tcx> {
- match ty::get(t).sty {
+ match t.sty {
ty::ty_infer(ty::TyVar(v)) => {
match self.probe(v) {
None => t,
main_span: Span) {
let tcx = ccx.tcx;
let main_t = ty::node_id_to_type(tcx, main_id);
- match ty::get(main_t).sty {
+ match main_t.sty {
ty::ty_bare_fn(..) => {
match tcx.map.find(main_id) {
Some(ast_map::NodeItem(it)) => {
start_span: Span) {
let tcx = ccx.tcx;
let start_t = ty::node_id_to_type(tcx, start_id);
- match ty::get(start_t).sty {
+ match start_t.sty {
ty::ty_bare_fn(_) => {
match tcx.map.find(start_id) {
Some(ast_map::NodeItem(it)) => {
variance: VarianceTermPtr<'a>) {
debug!("add_constraints_from_ty(ty={})", ty.repr(self.tcx()));
- match ty::get(ty).sty {
+ match ty.sty {
ty::ty_bool |
ty::ty_char | ty::ty_int(_) | ty::ty_uint(_) |
ty::ty_float(_) | ty::ty_str => {
self.visit_expr(&**sub_ex);
- let t = ty::expr_ty_adjusted(&self.analysis.ty_cx, &**sub_ex);
- let t_box = ty::get(t);
- match t_box.sty {
+ match ty::expr_ty_adjusted(&self.analysis.ty_cx, &**sub_ex).sty {
ty::ty_struct(def_id, _) => {
let fields = ty::lookup_struct_fields(&self.analysis.ty_cx, def_id);
for f in fields.iter() {
self.visit_expr(&**sub_ex);
- let t = ty::expr_ty_adjusted(&self.analysis.ty_cx, &**sub_ex);
- let t_box = ty::get(t);
- match t_box.sty {
+ match ty::expr_ty_adjusted(&self.analysis.ty_cx, &**sub_ex).sty {
ty::ty_struct(def_id, _) => {
let fields = ty::lookup_struct_fields(&self.analysis.ty_cx, def_id);
for (i, f) in fields.iter().enumerate() {
return Result::new(rs.bcx, rs.val);
}
- match ty::get(rhs_t).sty {
- ty::ty_rptr(_, mt) => match ty::get(mt.ty).sty {
+ match rhs_t.sty {
+ ty::ty_rptr(_, mt) => match mt.ty.sty {
ty::ty_str => compare_str(cx, lhs, rhs, rhs_t),
- ty::ty_vec(ty, _) => match ty::get(ty).sty {
+ ty::ty_vec(ty, _) => match ty.sty {
ty::ty_uint(ast::TyU8) => {
// NOTE: cast &[u8] to &str and abuse the str_eq lang item,
// which calls memcmp().
} else if any_uniq_pat(m, col) || any_region_pat(m, col) {
Some(vec!(Load(bcx, val)))
} else {
- match ty::get(left_ty).sty {
+ match left_ty.sty {
ty::ty_vec(_, Some(n)) => {
let args = extract_vec_elems(bcx, left_ty, n, 0, val);
Some(args.vals)
fn represent_type_uncached<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
t: Ty<'tcx>) -> Repr<'tcx> {
- match ty::get(t).sty {
+ match t.sty {
ty::ty_tup(ref elems) => {
Univariant(mk_struct(cx, elems.as_slice(), false, t), false)
}
fn find_ptr<'a>(&self, cx: &CrateContext<'a, 'tcx>) -> Option<PointerField> {
for (i, &ty) in self.tys.iter().enumerate() {
- match ty::get(ty).sty {
+ match ty.sty {
// &T/&mut T/Box<T> could either be a thin or fat pointer depending on T
- ty::ty_rptr(_, ty::mt { ty, .. }) | ty::ty_uniq(ty) => match ty::get(ty).sty {
+ ty::ty_rptr(_, ty::mt { ty, .. }) | ty::ty_uniq(ty) => match ty.sty {
// &[T] and &str are a pointer and length pair
ty::ty_vec(_, None) | ty::ty_str => return Some(FatPointer(i)),
pub fn decl_rust_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
fn_ty: Ty<'tcx>, name: &str) -> ValueRef {
- let (inputs, output, abi, env) = match ty::get(fn_ty).sty {
+ let (inputs, output, abi, env) = match fn_ty.sty {
ty::ty_bare_fn(ref f) => {
(f.sig.inputs.clone(), f.sig.output, f.abi, None)
}
-> Result<'blk, 'tcx> {
let f = |a| Result::new(cx, compare_scalar_values(cx, lhs, rhs, a, op));
- match ty::get(t).sty {
+ match t.sty {
ty::ty_tup(ref tys) if tys.is_empty() => f(nil_type),
ty::ty_bool | ty::ty_uint(_) | ty::ty_char => f(unsigned_int),
ty::ty_ptr(mt) if ty::type_is_sized(cx.tcx(), mt.ty) => f(unsigned_int),
size: uint,
op: ast::BinOp)
-> ValueRef {
- match ty::get(t).sty {
+ match t.sty {
ty::ty_float(_) => {
// The comparison operators for floating point vectors are challenging.
// LLVM outputs a `< size x i1 >`, but if we perform a sign extension
};
let mut cx = cx;
- match ty::get(t).sty {
+ match t.sty {
ty::ty_struct(..) => {
let repr = adt::represent_type(cx.ccx(), t);
expr::with_field_tys(cx.tcx(), t, None, |discr, field_tys| {
("attempted remainder with a divisor of zero",
"attempted remainder with overflow")
};
- let (is_zero, is_signed) = match ty::get(rhs_t).sty {
+ let (is_zero, is_signed) = match rhs_t.sty {
ty::ty_int(t) => {
let zero = C_integral(Type::int_from_ty(cx.ccx(), t), 0u64, false);
(ICmp(cx, llvm::IntEQ, rhs, zero), true)
// signed division/remainder which would trigger overflow. For unsigned
// integers, no action beyond checking for zero need be taken.
if is_signed {
- let (llty, min) = match ty::get(rhs_t).sty {
+ let (llty, min) = match rhs_t.sty {
ty::ty_int(t) => {
let llty = Type::int_from_ty(cx.ccx(), t);
let min = match t {
pub fn trans_external_path<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
did: ast::DefId, t: Ty<'tcx>) -> ValueRef {
let name = csearch::get_symbol(&ccx.sess().cstore, did);
- match ty::get(t).sty {
+ match t.sty {
ty::ty_bare_fn(ref fn_ty) => {
match ccx.sess().target.target.adjust_abi(fn_ty.abi) {
Rust | RustCall => {
}
// This is the last argument. Tuple it.
- match ty::get(arg_ty).sty {
+ match arg_ty.sty {
ty::ty_tup(ref tupled_arg_tys) => {
let tuple_args_scope_id = cleanup::CustomScope(arg_scope);
let tuple =
arg_datum.to_lvalue_datum_in_scope(bcx,
"argtuple",
arg_scope_id));
- let untupled_arg_types = match ty::get(monomorphized_arg_types[0]).sty {
+ let untupled_arg_types = match monomorphized_arg_types[0].sty {
ty::ty_tup(ref types) => types.as_slice(),
_ => {
bcx.tcx().sess.span_bug(args[0].pat.span,
let ccx = bcx.fcx.ccx;
let tcx = ccx.tcx();
- let result_ty = match ty::get(ctor_ty).sty {
+ let result_ty = match ctor_ty.sty {
ty::ty_bare_fn(ref bft) => bft.sig.output.unwrap(),
_ => ccx.sess().bug(
format!("trans_enum_variant_constructor: \
let ctor_ty = ty::node_id_to_type(ccx.tcx(), ctor_id);
let ctor_ty = ctor_ty.subst(ccx.tcx(), param_substs);
- let result_ty = match ty::get(ctor_ty).sty {
+ let result_ty = match ctor_ty.sty {
ty::ty_bare_fn(ref bft) => bft.sig.output,
_ => ccx.sess().bug(
format!("trans_enum_variant_or_tuple_like_struct: \
node_id: ast::NodeId,
node_type: Ty<'tcx>)
-> ValueRef {
- match ty::get(node_type).sty {
+ match node_type.sty {
ty::ty_bare_fn(ref f) => {
assert!(f.abi == Rust || f.abi == RustCall);
}
-> llvm::AttrBuilder {
use middle::ty::{BrAnon, ReLateBound};
- let (fn_sig, abi, has_env) = match ty::get(fn_ty).sty {
+ let (fn_sig, abi, has_env) = match fn_ty.sty {
ty::ty_closure(ref f) => (f.sig.clone(), f.abi, true),
ty::ty_bare_fn(ref f) => (f.sig.clone(), f.abi, false),
ty::ty_unboxed_closure(closure_did, _, ref substs) => {
// These have an odd calling convention, so we need to manually
// unpack the input ty's
- let input_tys = match ty::get(fn_ty).sty {
+ let input_tys = match fn_ty.sty {
ty::ty_unboxed_closure(_, _, _) => {
assert!(abi == RustCall);
- match ty::get(fn_sig.inputs[0]).sty {
+ match fn_sig.inputs[0].sty {
ty::ty_tup(ref inputs) => inputs.clone(),
_ => ccx.sess().bug("expected tuple'd inputs")
}
ty::ty_bare_fn(_) if abi == RustCall => {
let mut inputs = vec![fn_sig.inputs[0]];
- match ty::get(fn_sig.inputs[1]).sty {
+ match fn_sig.inputs[1].sty {
ty::ty_tup(ref t_in) => {
inputs.push_all(t_in.as_slice());
inputs
} else {
// The `noalias` attribute on the return value is useful to a
// function ptr caller.
- match ty::get(ret_ty).sty {
+ match ret_ty.sty {
// `~` pointer return values never alias because ownership
// is transferred
ty::ty_uniq(it) if !ty::type_is_sized(ccx.tcx(), it) => {}
}
// We can also mark the return value as `dereferenceable` in certain cases
- match ty::get(ret_ty).sty {
+ match ret_ty.sty {
// These are not really pointers but pairs, (pointer, len)
ty::ty_uniq(it) |
ty::ty_rptr(_, ty::mt { ty: it, .. }) if !ty::type_is_sized(ccx.tcx(), it) => {}
_ => {}
}
- match ty::get(ret_ty).sty {
+ match ret_ty.sty {
ty::ty_bool => {
attrs.ret(llvm::ZExtAttribute);
}
}
for (idx, &t) in input_tys.iter().enumerate().map(|(i, v)| (i + first_arg_offset, v)) {
- match ty::get(t).sty {
+ match t.sty {
// this needs to be first to prevent fat pointers from falling through
_ if !type_is_immediate(ccx, t) => {
let llarg_sz = llsize_of_real(ccx, type_of::type_of(ccx, t));
fn datum_callee<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, expr: &ast::Expr)
-> Callee<'blk, 'tcx> {
let DatumBlock {mut bcx, datum} = expr::trans(bcx, expr);
- match ty::get(datum.ty).sty {
+ match datum.ty.sty {
ty::ty_bare_fn(..) => {
let llval = datum.to_llscalarish(bcx);
return Callee {
data: NamedTupleConstructor(substs, 0)
}
}
- def::DefFn(did, _) if match ty::get(expr_ty).sty {
+ def::DefFn(did, _) if match expr_ty.sty {
ty::ty_bare_fn(ref f) => f.abi == synabi::RustIntrinsic,
_ => false
} => {
let callee = get_callee(bcx, cleanup::CustomScope(arg_cleanup_scope));
let mut bcx = callee.bcx;
- let (abi, ret_ty) = match ty::get(callee_ty).sty {
+ let (abi, ret_ty) = match callee_ty.sty {
ty::ty_bare_fn(ref f) => (f.abi, f.sig.output),
ty::ty_closure(ref f) => (f.abi, f.sig.output),
_ => panic!("expected bare rust fn or closure in trans_call_inner")
let tuple_expr = &arg_exprs[1];
let tuple_type = node_id_type(bcx, tuple_expr.id);
- match ty::get(tuple_type).sty {
+ match tuple_type.sty {
ty::ty_tup(ref field_types) => {
let tuple_datum = unpack_datum!(bcx,
expr::trans(bcx, &**tuple_expr));
// Now untuple the rest of the arguments.
let tuple_type = arg_tys[1];
- match ty::get(tuple_type).sty {
+ match tuple_type.sty {
ty::ty_tup(ref field_types) => {
for (i, &field_type) in field_types.iter().enumerate() {
let arg_datum =
use llvm::ValueRef;
use middle::def;
use middle::mem_categorization::Typer;
-use middle::subst::Substs;
use trans::adt;
use trans::base::*;
use trans::build::*;
// Normalize type so differences in regions and typedefs don't cause
// duplicate declarations
let function_type = ty::normalize_ty(bcx.tcx(), function_type);
- let params = match ty::get(function_type).sty {
+ let params = match function_type.sty {
ty::ty_unboxed_closure(_, _, ref substs) => substs.types.clone(),
_ => unreachable!()
};
debug!("get_wrapper_for_bare_fn(closure_ty={})", closure_ty.repr(tcx));
- let f = match ty::get(closure_ty).sty {
+ let f = match closure_ty.sty {
ty::ty_closure(ref f) => f,
_ => {
ccx.sess().bug(format!("get_wrapper_for_bare_fn: \
fn type_is_newtype_immediate<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
ty: Ty<'tcx>) -> bool {
- match ty::get(ty).sty {
+ match ty.sty {
ty::ty_struct(def_id, ref substs) => {
let fields = ty::struct_fields(ccx.tcx(), def_id, substs);
fields.len() == 1 &&
if !ty::type_is_sized(tcx, ty) {
return false;
}
- match ty::get(ty).sty {
+ match ty.sty {
ty::ty_struct(..) | ty::ty_enum(..) | ty::ty_tup(..) |
ty::ty_unboxed_closure(..) => {
let llty = sizing_type_of(ccx, ty);
}
ast::LitInt(i, ast::UnsuffixedIntLit(_)) => {
let lit_int_ty = ty::node_id_to_type(cx.tcx(), e.id);
- match ty::get(lit_int_ty).sty {
+ match lit_int_ty.sty {
ty::ty_int(t) => {
C_integral(Type::int_from_ty(cx, t), i as u64, true)
}
}
ast::LitFloatUnsuffixed(ref fs) => {
let lit_float_ty = ty::node_id_to_type(cx.tcx(), e.id);
- match ty::get(lit_float_ty).sty {
+ match lit_float_ty.sty {
ty::ty_float(t) => {
C_floating(fs.get(), Type::float_from_ty(cx, t))
}
-> (ValueRef, Ty<'tcx>) {
match ty::deref(t, explicit) {
Some(ref mt) => {
- match ty::get(t).sty {
+ match t.sty {
ty::ty_ptr(mt) | ty::ty_rptr(_, mt) => {
if ty::type_is_sized(cx.tcx(), mt.ty) {
(const_deref_ptr(cx, v), mt.ty)
llconst = const_addr_of(cx, llconst, ast::MutImmutable)
}
- match ty::get(ty).sty {
+ match ty.sty {
ty::ty_vec(unit_ty, Some(len)) => {
let llunitty = type_of::type_of(cx, unit_ty);
let llptr = const_ptrcast(cx, llconst, llunitty);
_ => cx.sess().span_bug(index.span,
"index is not an integer-constant expression")
};
- let (arr, len) = match ty::get(bt).sty {
+ let (arr, len) = match bt.sty {
ty::ty_vec(_, Some(u)) => (bv, C_uint(cx, u)),
- ty::ty_open(ty) => match ty::get(ty).sty {
+ ty::ty_open(ty) => match ty.sty {
ty::ty_vec(_, None) | ty::ty_str => {
let e1 = const_get_elt(cx, bv, &[0]);
(const_deref_ptr(cx, e1), const_get_elt(cx, bv, &[1]))
or string type, found {}",
ty_to_string(cx.tcx(), bt)).as_slice())
},
- ty::ty_rptr(_, mt) => match ty::get(mt.ty).sty {
+ ty::ty_rptr(_, mt) => match mt.ty.sty {
ty::ty_vec(_, Some(u)) => {
(const_deref_ptr(cx, bv), C_uint(cx, u))
},
};
let len = llvm::LLVMConstIntGetZExtValue(len) as u64;
- let len = match ty::get(bt).sty {
- ty::ty_uniq(ty) | ty::ty_rptr(_, ty::mt{ty, ..}) => match ty::get(ty).sty {
+ let len = match bt.sty {
+ ty::ty_uniq(ty) | ty::ty_rptr(_, ty::mt{ty, ..}) => match ty.sty {
ty::ty_str => {
assert!(len > 0);
len - 1
pub fn get_element<'blk>(&self, bcx: Block<'blk, 'tcx>, ty: Ty<'tcx>,
gep: |ValueRef| -> ValueRef)
-> Datum<'tcx, Lvalue> {
- let val = match ty::get(self.ty).sty {
+ let val = match self.ty.sty {
_ if ty::type_is_sized(bcx.tcx(), self.ty) => gep(self.val),
ty::ty_open(_) => {
let base = Load(bcx, expr::get_dataptr(bcx, self.val));
let mut unique_type_id = String::with_capacity(256);
unique_type_id.push('{');
- match ty::get(type_).sty {
+ match type_.sty {
ty::ty_bool |
ty::ty_char |
ty::ty_str |
_ => {
cx.sess().bug(format!("get_unique_type_id_of_type() - unexpected type: {}, {}",
ppaux::ty_to_string(cx.tcx(), type_).as_slice(),
- ty::get(type_).sty).as_slice())
+ type_.sty).as_slice())
}
};
fn basic_type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
t: Ty<'tcx>) -> DIType {
- debug!("basic_type_metadata: {}", ty::get(t));
+ debug!("basic_type_metadata: {}", t);
- let (name, encoding) = match ty::get(t).sty {
+ let (name, encoding) = match t.sty {
ty::ty_tup(ref elements) if elements.is_empty() =>
("()".to_string(), DW_ATE_unsigned),
ty::ty_bool => ("bool".to_string(), DW_ATE_boolean),
// return type
signature_metadata.push(match signature.output {
- ty::FnConverging(ret_ty) => match ty::get(ret_ty).sty {
+ ty::FnConverging(ret_ty) => match ret_ty.sty {
ty::ty_tup(ref tys) if tys.is_empty() => ptr::null_mut(),
_ => type_metadata(cx, ret_ty, span)
},
// type is assigned the correct name, size, namespace, and source location.
// But it does not describe the trait's methods.
- let def_id = match ty::get(trait_type).sty {
+ let def_id = match trait_type.sty {
ty::ty_trait(box ty::TyTrait { ref principal, .. }) => principal.def_id,
_ => {
let pp_type_name = ppaux::ty_to_string(cx.tcx(), trait_type);
}
};
- debug!("type_metadata: {}", ty::get(t));
+ debug!("type_metadata: {}", t);
- let sty = &ty::get(t).sty;
+ let sty = &t.sty;
let MetadataCreationResult { metadata, already_stored_in_typemap } = match *sty {
ty::ty_bool |
ty::ty_char |
false)
}
ty::ty_uniq(ty) | ty::ty_ptr(ty::mt{ty, ..}) | ty::ty_rptr(_, ty::mt{ty, ..}) => {
- match ty::get(ty).sty {
+ match ty.sty {
ty::ty_vec(typ, None) => {
vec_slice_metadata(cx, t, typ, unique_type_id, usage_site_span)
}
t: Ty<'tcx>,
qualified: bool,
output: &mut String) {
- match ty::get(t).sty {
+ match t.sty {
ty::ty_bool => output.push_str("bool"),
ty::ty_char => output.push_str("char"),
ty::ty_str => output.push_str("str"),
// also be just in case we need to unsize. But if there are no nested
// adjustments then it should be a no-op).
Some(ty::AutoPtr(_, _, None)) if adj.autoderefs == 1 => {
- match ty::get(datum.ty).sty {
+ match datum.ty.sty {
// Don't skip a conversion from Box<T> to &T, etc.
ty::ty_rptr(..) => {
let method_call = MethodCall::autoderef(expr.id, adj.autoderefs-1);
mk_ty: |Ty<'tcx>| -> Ty<'tcx>) -> ValueRef {
match kind {
&ty::UnsizeLength(len) => C_uint(bcx.ccx(), len),
- &ty::UnsizeStruct(box ref k, tp_index) => match ty::get(unsized_ty).sty {
+ &ty::UnsizeStruct(box ref k, tp_index) => match unsized_ty.sty {
ty::ty_struct(_, ref substs) => {
let ty_substs = substs.types.get_slice(subst::TypeSpace);
// The dtor for a field treats it like a value, so mk_ty
let tcx = bcx.tcx();
let datum_ty = datum.ty;
- let unboxed_ty = match ty::get(datum_ty).sty {
+ let unboxed_ty = match datum_ty.sty {
ty::ty_uniq(t) => t,
_ => bcx.sess().bug(format!("Expected ty_uniq, found {}",
bcx.ty_to_string(datum_ty)).as_slice())
// Special case for `Box<T>`
let box_ty = expr_ty(bcx, expr);
let contents_ty = expr_ty(bcx, &**contents);
- match ty::get(box_ty).sty {
+ match box_ty.sty {
ty::ty_uniq(..) => {
trans_uniq_expr(bcx, box_ty, &**contents, contents_ty)
}
}
def::DefStruct(_) => {
let ty = expr_ty(bcx, ref_expr);
- match ty::get(ty).sty {
+ match ty.sty {
ty::ty_struct(did, _) if ty::has_dtor(bcx.tcx(), did) => {
let repr = adt::represent_type(bcx.ccx(), ty);
adt::trans_set_discr(bcx, &*repr, lldest, 0);
* is and `node_id_opt` is none, this function panics).
*/
- match ty::get(ty).sty {
+ match ty.sty {
ty::ty_struct(did, ref substs) => {
op(0, struct_fields(tcx, did, substs).as_slice())
}
let _icx = push_ctxt("trans_addr_of");
let mut bcx = bcx;
let sub_datum = unpack_datum!(bcx, trans_to_lvalue(bcx, subexpr, "addr_of"));
- match ty::get(sub_datum.ty).sty {
+ match sub_datum.ty.sty {
ty::ty_open(_) => {
// Opened DST value, close to a fat pointer
debug!("Closing fat pointer {}", bcx.ty_to_string(sub_datum.ty));
}
pub fn cast_type_kind<'tcx>(tcx: &ty::ctxt<'tcx>, t: Ty<'tcx>) -> cast_kind {
- match ty::get(t).sty {
+ match t.sty {
ty::ty_char => cast_integral,
ty::ty_float(..) => cast_float,
ty::ty_rptr(_, mt) | ty::ty_ptr(mt) => {
}
};
- let r = match ty::get(datum.ty).sty {
+ let r = match datum.ty.sty {
ty::ty_uniq(content_ty) => {
if ty::type_is_sized(bcx.tcx(), content_ty) {
deref_owned_pointer(bcx, expr, datum, content_ty)
"invalid linkage specified");
}
};
- let llty2 = match ty::get(ty).sty {
+ let llty2 = match ty.sty {
ty::ty_ptr(ref mt) => type_of::type_of(ccx, mt.ty),
_ => {
ccx.sess().span_fatal(foreign_item.span,
ccx.tn().val_to_string(llfn),
ccx.tn().val_to_string(llretptr));
- let (fn_abi, fn_sig) = match ty::get(callee_ty).sty {
+ let (fn_abi, fn_sig) = match callee_ty.sty {
ty::ty_bare_fn(ref fn_ty) => (fn_ty.abi, fn_ty.sig.clone()),
_ => ccx.sess().bug("trans_native_call called on non-function type")
};
-> ValueRef {
let tys = foreign_types_for_fn_ty(ccx, t);
let llfn_ty = lltype_for_fn_from_foreign_types(ccx, &tys);
- let cconv = match ty::get(t).sty {
+ let cconv = match t.sty {
ty::ty_bare_fn(ref fn_ty) => {
llvm_calling_convention(ccx, fn_ty.abi)
}
let tys = foreign_types_for_id(ccx, node_id);
let llfn_ty = lltype_for_fn_from_foreign_types(ccx, &tys);
let t = ty::node_id_to_type(ccx.tcx(), node_id);
- let cconv = match ty::get(t).sty {
+ let cconv = match t.sty {
ty::ty_bare_fn(ref fn_ty) => {
llvm_calling_convention(ccx, fn_ty.abi)
}
// Compute the type that the function would have if it were just a
// normal Rust function. This will be the type of the wrappee fn.
- match ty::get(t).sty {
+ match t.sty {
ty::ty_bare_fn(ref f) => {
assert!(f.abi != Rust && f.abi != RustIntrinsic);
}
fn foreign_types_for_fn_ty<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
ty: Ty<'tcx>) -> ForeignTypes<'tcx> {
- let fn_sig = match ty::get(ty).sty {
+ let fn_sig = match ty.sty {
ty::ty_bare_fn(ref fn_ty) => fn_ty.sig.clone(),
_ => ccx.sess().bug("foreign_types_for_fn_ty called on non-function type")
};
if !ty::type_needs_drop(tcx, t) {
return ty::mk_i8();
}
- match ty::get(t).sty {
+ match t.sty {
ty::ty_uniq(typ) if !ty::type_needs_drop(tcx, typ)
&& ty::type_is_sized(tcx, typ) => {
let llty = sizing_type_of(ccx, typ);
};
let fty = ty::lookup_item_type(bcx.tcx(), dtor_did).ty.subst(bcx.tcx(), substs);
- let self_ty = match ty::get(fty).sty {
+ let self_ty = match fty.sty {
ty::ty_bare_fn(ref f) => {
assert!(f.sig.inputs.len() == 1);
f.sig.inputs[0]
let align = C_uint(bcx.ccx(), align_of(bcx.ccx(), t));
return (size, align);
}
- match ty::get(t).sty {
+ match t.sty {
ty::ty_struct(id, ref substs) => {
let ccx = bcx.ccx();
// First get the size of all statically known fields.
-> Block<'blk, 'tcx> {
// NB: v0 is an *alias* of type t here, not a direct value.
let _icx = push_ctxt("make_drop_glue");
- match ty::get(t).sty {
+ match t.sty {
ty::ty_uniq(content_ty) => {
- match ty::get(content_ty).sty {
+ match content_ty.sty {
ty::ty_vec(ty, None) => {
tvec::make_drop_glue_unboxed(bcx, v0, ty, true)
}
let ccx = fcx.ccx;
let tcx = bcx.tcx();
- let ret_ty = match ty::get(callee_ty).sty {
+ let ret_ty = match callee_ty.sty {
ty::ty_bare_fn(ref f) => f.sig.output,
_ => panic!("expected bare_fn in trans_intrinsic_call")
};
// Load the function from the vtable and cast it to the expected type.
debug!("(translating trait callee) loading method");
// Replace the self type (&Self or Box<Self>) with an opaque pointer.
- let llcallee_ty = match ty::get(callee_ty).sty {
+ let llcallee_ty = match callee_ty.sty {
ty::ty_bare_fn(ref f) if f.abi == Rust || f.abi == RustCall => {
type_of_rust_fn(ccx,
Some(Type::i8p(ccx)),
unboxed closure");
if closure_info.kind == ty::FnOnceUnboxedClosureKind {
// Untuple the arguments and create an unboxing shim.
- let (new_inputs, new_output) = match ty::get(self_ty).sty {
+ let (new_inputs, new_output) = match self_ty.sty {
ty::ty_unboxed_closure(_, _, ref substs) => {
let mut new_inputs = vec![self_ty.clone()];
- match ty::get(closure_info.closure_type
- .sig
- .inputs[0]).sty {
+ match closure_info.closure_type.sig.inputs[0].sty {
ty::ty_tup(ref elements) => {
for element in elements.iter() {
new_inputs.push(element.subst(bcx.tcx(), substs));
let ccx = bcx.ccx();
- match ty::get(vec_ty).sty {
+ match vec_ty.sty {
ty::ty_vec(_, Some(n)) => get_fixed_base_and_len(bcx, llval, n),
- ty::ty_open(ty) => match ty::get(ty).sty {
+ ty::ty_open(ty) => match ty.sty {
ty::ty_vec(_, None) | ty::ty_str => get_slice_base_and_len(bcx, llval),
_ => ccx.sess().bug("unexpected type in get_base_and_len")
},
// Only used for pattern matching.
- ty::ty_uniq(ty) | ty::ty_rptr(_, ty::mt{ty, ..}) => match ty::get(ty).sty {
+ ty::ty_uniq(ty) | ty::ty_rptr(_, ty::mt{ty, ..}) => match ty.sty {
ty::ty_vec(_, None) | ty::ty_str => get_slice_base_and_len(bcx, llval),
ty::ty_vec(_, Some(n)) => {
let base = GEPi(bcx, Load(bcx, llval), &[0u, 0u]);
}
}
- match ty::get(inputs[inputs.len() - 1]).sty {
+ match inputs[inputs.len() - 1].sty {
ty::ty_tup(ref tupled_arguments) => {
debug!("untuple_arguments_if_necessary(): untupling arguments");
for &tupled_argument in tupled_arguments.iter() {
// Given a function type and a count of ty params, construct an llvm type
pub fn type_of_fn_from_ty<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, fty: Ty<'tcx>) -> Type {
- match ty::get(fty).sty {
+ match fty.sty {
ty::ty_closure(ref f) => {
type_of_rust_fn(cx,
Some(Type::i8p(cx)),
None => ()
}
- let llsizingty = match ty::get(t).sty {
+ let llsizingty = match t.sty {
_ if !ty::lltype_is_sized(cx.tcx(), t) => {
cx.sess().bug(format!("trying to take the sizing type of {}, an unsized type",
ppaux::ty_to_string(cx.tcx(), t)).as_slice())
return Type::i8p(cx);
}
- match ty::get(ty::unsized_part_of_type(cx.tcx(), t)).sty {
+ match ty::unsized_part_of_type(cx.tcx(), t).sty {
ty::ty_str | ty::ty_vec(..) => Type::uint_from_ty(cx, ast::TyU),
ty::ty_trait(_) => Type::vtable_ptr(cx),
_ => panic!("Unexpected type returned from unsized_part_of_type : {}",
None => ()
}
- debug!("type_of {} {}", t.repr(cx.tcx()), ty::get(t).sty);
+ debug!("type_of {} {}", t.repr(cx.tcx()), t.sty);
// Replace any typedef'd types with their equivalent non-typedef
// type. This ensures that all LLVM nominal types that contain
return llty;
}
- let mut llty = match ty::get(t).sty {
+ let mut llty = match t.sty {
ty::ty_bool => Type::bool(cx),
ty::ty_char => Type::char(cx),
ty::ty_int(t) => Type::int_from_ty(cx, t),
}
ty::ty_uniq(ty) | ty::ty_rptr(_, ty::mt{ty, ..}) | ty::ty_ptr(ty::mt{ty, ..}) => {
- match ty::get(ty).sty {
+ match ty.sty {
ty::ty_str => {
// This means we get a nicer name in the output (str is always
// unsized).
}
}
- ty::ty_open(t) => match ty::get(t).sty {
+ ty::ty_open(t) => match t.sty {
ty::ty_struct(..) => {
let p_ty = type_of(cx, t).ptr_to();
Type::struct_(cx, &[p_ty, type_of_unsize_info(cx, t)], false)
cx.lltypes().borrow_mut().insert(t, llty);
// If this was an enum or struct, fill in the type now.
- match ty::get(t).sty {
+ match t.sty {
ty::ty_enum(..) | ty::ty_struct(..) | ty::ty_unboxed_closure(..)
if !ty::type_is_simd(cx.tcx(), t) => {
let repr = adt::represent_type(cx, t);
fn build_external_function(cx: &DocContext, tcx: &ty::ctxt, did: ast::DefId) -> clean::Function {
let t = ty::lookup_item_type(tcx, did);
- let (decl, style) = match ty::get(t.ty).sty {
+ let (decl, style) = match t.ty.sty {
ty::ty_bare_fn(ref f) => ((did, &f.sig).clean(cx), f.fn_style),
_ => panic!("bad function"),
};
fn build_type(cx: &DocContext, tcx: &ty::ctxt, did: ast::DefId) -> clean::ItemEnum {
let t = ty::lookup_item_type(tcx, did);
- match ty::get(t.ty).sty {
+ match t.ty.sty {
ty::ty_enum(edid, _) if !csearch::is_typedef(&tcx.sess.cstore, did) => {
return clean::EnumItem(clean::Enum {
generics: (&t.generics, subst::TypeSpace).clean(cx),
let s = match s {
ty::ByValueExplicitSelfCategory => SelfValue,
ty::ByReferenceExplicitSelfCategory(..) => {
- match ty::get(self.fty.sig.inputs[0]).sty {
+ match self.fty.sig.inputs[0].sty {
ty::ty_rptr(r, mt) => {
SelfBorrowed(r.clean(cx), mt.mutbl.clean(cx))
}
impl Clean<Type> for Ty {
fn clean(&self, cx: &DocContext) -> Type {
- match ty::get(*self).sty {
+ match self.sty {
ty::ty_bool => Primitive(Bool),
ty::ty_char => Primitive(Char),
ty::ty_int(ast::TyI) => Primitive(Int),
let fqn: Vec<String> = fqn.into_iter().map(|i| {
i.to_string()
}).collect();
- let kind = match ty::get(*self).sty {
+ let kind = match self.sty {
ty::ty_struct(..) => TypeStruct,
ty::ty_trait(..) => TypeTrait,
_ => TypeEnum,