rustc: middle: remove obsolete ty::get.

This commit is contained in:
Eduard Burtescu 2014-10-31 10:51:16 +02:00
parent 01105ffde3
commit 9f7aa7fa76
65 changed files with 326 additions and 346 deletions

View File

@ -100,7 +100,7 @@ impl LintPass for UnusedCasts {
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");
}
}
@ -156,7 +156,7 @@ impl LintPass for TypeLimits {
},
_ => {
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 \
@ -181,7 +181,7 @@ impl LintPass for TypeLimits {
}
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
@ -206,7 +206,7 @@ impl LintPass for TypeLimits {
}
},
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)) |
@ -344,7 +344,7 @@ impl LintPass for TypeLimits {
// 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 {
@ -478,7 +478,7 @@ impl BoxPointers {
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,
@ -578,7 +578,7 @@ impl LintPass for RawPointerDeriving {
}
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,
@ -740,7 +740,7 @@ impl LintPass for UnusedResults {
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, _) |

View File

@ -699,7 +699,7 @@ pub fn get_enum_variants<'tcx>(intr: Rc<IdentInterner>, cdata: Cmd, id: ast::Nod
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.

View File

@ -54,7 +54,7 @@ pub fn enc_ty<'a, 'tcx>(w: &mut SeekableMemWriter, cx: &ctxt<'a, 'tcx>, t: Ty<'t
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 {

View File

@ -146,7 +146,7 @@ fn check_and_get_illegal_move_origin<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
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())

View File

@ -126,7 +126,7 @@ fn report_cannot_move_out_of<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
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(

View File

@ -589,7 +589,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
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(..),
..

View File

@ -406,7 +406,7 @@ fn construct_witness(cx: &MatchCheckCtxt, ctor: &Constructor,
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, _) => {
@ -438,7 +438,7 @@ fn construct_witness(cx: &MatchCheckCtxt, ctor: &Constructor,
}
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);
@ -498,11 +498,11 @@ fn missing_constructor(cx: &MatchCheckCtxt, &Matrix(ref rows): &Matrix,
/// 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)
@ -671,7 +671,7 @@ fn pat_constructors(cx: &MatchCheckCtxt, p: &Pat,
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)
@ -696,10 +696,10 @@ fn pat_constructors(cx: &MatchCheckCtxt, p: &Pat,
/// 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,

View File

@ -162,7 +162,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for CheckStaticVisitor<'a, 'tcx> {
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,

View File

@ -524,7 +524,7 @@ pub fn eval_const_expr_partial(tcx: &ty::ctxt, e: &Expr) -> Result<const_val, St
$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)),

View File

@ -140,7 +140,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
}
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()
@ -152,7 +152,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
}
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;

View File

@ -31,7 +31,7 @@ enum UnsafeContext {
}
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,
@ -70,8 +70,8 @@ impl<'a, 'tcx> EffectCheckVisitor<'a, 'tcx> {
};
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");
@ -166,7 +166,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for EffectCheckVisitor<'a, 'tcx> {
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")

View File

@ -519,7 +519,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
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);
}
@ -656,7 +656,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
// 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)
}
@ -745,7 +745,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
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 {}",

View File

@ -53,7 +53,7 @@ pub fn simplify_type(tcx: &ty::ctxt,
* 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)),

View File

@ -27,7 +27,7 @@ fn type_size_is_affected_by_type_parameters<'tcx>(tcx: &ty::ctxt<'tcx>, typ: Ty<
-> 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
@ -73,7 +73,7 @@ struct IntrinsicCheckingVisitor<'a, 'tcx: 'a> {
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
};
@ -123,7 +123,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for IntrinsicCheckingVisitor<'a, 'tcx> {
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 {

View File

@ -1520,7 +1520,7 @@ fn check_fn(_v: &Liveness,
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()
@ -1550,8 +1550,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
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
},

View File

@ -197,7 +197,7 @@ pub enum deref_kind {
// 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))
@ -585,7 +585,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
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
@ -808,7 +808,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
-> 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)
}
@ -1069,8 +1069,8 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
* 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),
},
@ -1533,9 +1533,9 @@ impl<'tcx> Repr<'tcx> for InteriorKind {
}
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
},

View File

@ -667,7 +667,7 @@ impl<'a, 'tcx> PrivacyVisitor<'a, 'tcx> {
}
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
@ -837,7 +837,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for PrivacyVisitor<'a, 'tcx> {
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));
}
@ -845,7 +845,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for PrivacyVisitor<'a, 'tcx> {
}
}
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));
}
@ -867,7 +867,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for PrivacyVisitor<'a, 'tcx> {
}
}
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,
@ -976,7 +976,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for PrivacyVisitor<'a, 'tcx> {
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,
@ -1007,7 +1007,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for PrivacyVisitor<'a, 'tcx> {
// 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 {

View File

@ -641,7 +641,7 @@ impl<'a, 'tcx> TypeFolder<'tcx> for SubstFolder<'a, 'tcx> {
}
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)
}

View File

@ -79,7 +79,7 @@ pub fn impl_is_local(tcx: &ty::ctxt,
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(..) |

View File

@ -1030,7 +1030,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
};
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;
@ -1233,7 +1233,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
-> 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(_) |

View File

@ -653,28 +653,21 @@ impl<'tcx> BorrowFrom<InternedTy<'tcx>> for sty<'tcx> {
}
}
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 {
@ -714,7 +707,7 @@ 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)]
@ -1929,9 +1922,8 @@ impl FlagComputation {
}
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]) {
@ -2211,7 +2203,7 @@ pub fn maybe_walk_ty<'tcx>(ty: Ty<'tcx>, f: |Ty<'tcx>| -> bool) {
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),
@ -2302,18 +2294,18 @@ impl<'tcx> ParamBounds<'tcx> {
// 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 {
@ -2321,24 +2313,24 @@ 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,
},
@ -2347,10 +2339,10 @@ fn type_is_slice(ty: Ty) -> bool {
}
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
},
@ -2359,7 +2351,7 @@ pub fn type_is_vec(ty: Ty) -> bool {
}
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)
@ -2367,14 +2359,14 @@ pub fn type_is_structural(ty: Ty) -> bool {
}
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),
@ -2384,7 +2376,7 @@ pub fn sequence_element_type<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx> {
}
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)
@ -2394,7 +2386,7 @@ pub fn simd_type<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx> {
}
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()
@ -2404,22 +2396,22 @@ pub fn simd_size(cx: &ctxt, ty: Ty) -> uint {
}
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
},
@ -2428,7 +2420,7 @@ pub fn type_is_unique(ty: Ty) -> bool {
}
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,
@ -2441,7 +2433,7 @@ pub fn type_is_fat_ptr<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> bool {
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,
@ -2452,7 +2444,7 @@ pub fn type_is_scalar(ty: Ty) -> bool {
/// 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,
}
@ -2480,7 +2472,7 @@ pub fn type_needs_unwind_cleanup<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> bool {
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,
@ -2732,7 +2724,7 @@ pub fn type_contents<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> TypeContents {
}
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
@ -2750,7 +2742,7 @@ pub fn type_contents<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> TypeContents {
}
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(),
}
@ -2765,7 +2757,7 @@ pub fn type_contents<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> TypeContents {
}
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)),
@ -2852,7 +2844,7 @@ pub fn type_contents<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> TypeContents {
}
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; }
_ => { }
}
@ -3026,10 +3018,7 @@ pub fn is_instantiable<'tcx>(cx: &ctxt<'tcx>, r_ty: Ty<'tcx>) -> bool {
::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),
@ -3044,7 +3033,7 @@ pub fn is_instantiable<'tcx>(cx: &ctxt<'tcx>, r_ty: Ty<'tcx>) -> bool {
::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.
@ -3163,7 +3152,7 @@ pub fn is_type_representable<'tcx>(cx: &ctxt<'tcx>, sp: Span, ty: Ty<'tcx>)
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))
}
@ -3193,7 +3182,7 @@ pub fn is_type_representable<'tcx>(cx: &ctxt<'tcx>, sp: Span, ty: Ty<'tcx>)
}
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
}
@ -3202,7 +3191,7 @@ pub fn is_type_representable<'tcx>(cx: &ctxt<'tcx>, sp: Span, ty: Ty<'tcx>)
}
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 {
@ -3230,7 +3219,7 @@ pub fn is_type_representable<'tcx>(cx: &ctxt<'tcx>, sp: Span, ty: Ty<'tcx>)
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.
@ -3307,8 +3296,8 @@ pub fn type_is_trait(ty: Ty) -> bool {
}
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
},
@ -3318,14 +3307,14 @@ pub fn type_trait_info<'tcx>(ty: Ty<'tcx>) -> Option<&'tcx TyTrait<'tcx>> {
}
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
@ -3333,28 +3322,28 @@ pub fn type_is_skolemized(ty: Ty) -> bool {
}
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
}
@ -3365,14 +3354,14 @@ pub fn type_is_numeric(ty: Ty) -> bool {
}
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
@ -3385,7 +3374,7 @@ pub fn type_is_sized<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> bool {
}
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)
}
@ -3395,7 +3384,7 @@ pub fn lltype_is_sized<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> bool {
// '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()
@ -3416,7 +3405,7 @@ pub fn unsized_part_of_type<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx> {
// 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 {
@ -3434,7 +3423,7 @@ pub fn type_is_c_like_enum(cx: &ctxt, ty: Ty) -> bool {
// 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,
@ -3448,7 +3437,7 @@ pub fn deref<'tcx>(ty: Ty<'tcx>, explicit: bool) -> Option<mt<'tcx>> {
}
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
@ -3456,7 +3445,7 @@ pub fn deref_or_dont<'tcx>(ty: Ty<'tcx>) -> Ty<'tcx> {
}
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())
@ -3464,7 +3453,7 @@ pub fn close_type<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx> {
}
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
@ -3473,7 +3462,7 @@ pub fn type_content<'tcx>(ty: Ty<'tcx>) -> Ty<'tcx> {
// 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
}
@ -3481,7 +3470,7 @@ pub fn unopen_type<'tcx>(ty: Ty<'tcx>) -> Ty<'tcx> {
// 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
}
@ -3491,7 +3480,7 @@ pub fn index<'tcx>(ty: Ty<'tcx>) -> Option<Ty<'tcx>> {
// 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
@ -3536,7 +3525,7 @@ pub fn node_id_item_substs<'tcx>(cx: &ctxt<'tcx>, id: ast::NodeId) -> ItemSubsts
}
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 => {
@ -3546,7 +3535,7 @@ pub fn fn_is_variadic(fty: Ty) -> bool {
}
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 => {
@ -3557,7 +3546,7 @@ pub fn ty_fn_sig<'tcx>(fty: Ty<'tcx>) -> &'tcx FnSig<'tcx> {
/// 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"),
@ -3570,7 +3559,7 @@ pub fn ty_fn_args<'tcx>(fty: Ty<'tcx>) -> &'tcx [Ty<'tcx>] {
}
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
@ -3584,7 +3573,7 @@ pub fn ty_closure_store(fty: Ty) -> TraitStore {
}
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 => {
@ -3594,7 +3583,7 @@ pub fn ty_fn_ret<'tcx>(fty: Ty<'tcx>) -> FnOutput<'tcx> {
}
pub fn is_fn_ty(fty: Ty) -> bool {
match get(fty).sty {
match fty.sty {
ty_bare_fn(_) => true,
ty_closure(_) => true,
_ => false
@ -3604,7 +3593,7 @@ pub fn is_fn_ty(fty: Ty) -> bool {
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(
@ -3716,7 +3705,7 @@ pub fn adjust_ty<'tcx>(cx: &ctxt<'tcx>,
-> Ty<'tcx> {
/*! See `expr_ty_adjusted` */
match get(unadjusted_ty).sty {
match unadjusted_ty.sty {
ty_err => return unadjusted_ty,
_ => {}
}
@ -3725,7 +3714,7 @@ pub fn adjust_ty<'tcx>(cx: &ctxt<'tcx>,
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,
@ -3829,7 +3818,7 @@ pub fn unsize_ty<'tcx>(cx: &ctxt<'tcx>,
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)
@ -3838,7 +3827,7 @@ pub fn unsize_ty<'tcx>(cx: &ctxt<'tcx>,
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);
@ -3925,7 +3914,7 @@ pub fn expr_kind(tcx: &ctxt, expr: &ast::Expr) -> ExprKind {
}
def::DefStruct(_) => {
match get(expr_ty(tcx, expr)).sty {
match expr_ty(tcx, expr).sty {
ty_bare_fn(..) => RvalueDatumExpr,
_ => RvalueDpsExpr
}
@ -4089,7 +4078,7 @@ pub fn impl_or_trait_item_idx(id: ast::Name, trait_items: &[ImplOrTraitItem])
}
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)
@ -4529,7 +4518,7 @@ pub fn try_add_builtin_trait(
}
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, _) |
@ -4684,7 +4673,7 @@ pub fn enum_is_univariant(cx: &ctxt, id: ast::DefId) -> bool {
}
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
}
@ -5108,7 +5097,7 @@ pub fn is_binopable<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>, op: ast::BinOp) -> bool
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,
@ -5534,7 +5523,7 @@ pub fn hash_crate_independent(tcx: &ctxt, ty: Ty, svh: &Svh) -> u64 {
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) => {
@ -5870,7 +5859,7 @@ pub enum ExplicitSelfCategory {
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)
}

View File

@ -490,7 +490,7 @@ impl<'tcx> TypeFoldable<'tcx> for traits::VtableParamData<'tcx> {
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)
}

View File

@ -667,7 +667,7 @@ pub fn ast_ty_to_builtin_ty<'tcx, AC: AstConv<'tcx>, RS: RegionScope>(
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);
@ -1294,7 +1294,7 @@ fn determine_explicit_self_category<'a, 'tcx, AC: AstConv<'tcx>,
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,
@ -1304,7 +1304,7 @@ fn determine_explicit_self_category<'a, 'tcx, AC: AstConv<'tcx>,
};
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,

View File

@ -165,7 +165,7 @@ pub fn check_pat<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>,
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 {
@ -217,7 +217,7 @@ pub fn check_dereferencable<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>,
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.
@ -313,7 +313,7 @@ pub fn check_pat_struct<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>, pat: &ast::Pat,
},
_ => {
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, _)
@ -378,7 +378,7 @@ pub fn check_pat_enum<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>, pat: &ast::Pat,
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<_>>(),

View File

@ -305,7 +305,7 @@ impl<'a,'tcx> ConfirmContext<'a,'tcx> {
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,
}
@ -482,13 +482,13 @@ impl<'a,'tcx> ConfirmContext<'a,'tcx> {
* `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,

View File

@ -262,7 +262,7 @@ pub fn lookup_in_trait_adjusted<'a, 'tcx>(fcx: &'a FnCtxt<'a, 'tcx>,
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);
@ -321,7 +321,7 @@ pub fn report_error<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
// 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()

View File

@ -173,7 +173,7 @@ fn create_steps<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
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),
@ -186,9 +186,9 @@ fn create_steps<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
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),
}
@ -238,7 +238,7 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> {
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);
@ -562,7 +562,7 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> {
// 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,
};
@ -638,7 +638,7 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> {
// 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
}

View File

@ -405,7 +405,7 @@ fn check_bare_fn<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
// (replace any type-scheme with a type)
let fty = fty.subst(ccx.tcx, &param_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,
@ -1436,7 +1436,7 @@ fn check_cast(fcx: &FnCtxt,
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 ",
@ -1505,19 +1505,19 @@ fn check_cast(fcx: &FnCtxt,
// 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
}
@ -1545,7 +1545,7 @@ fn check_cast(fcx: &FnCtxt,
/* 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) => {
@ -2370,7 +2370,7 @@ fn autoderef_for_index<'a, 'tcx, T>(fcx: &FnCtxt<'a, 'tcx>,
// 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 {
@ -2653,7 +2653,7 @@ fn lookup_method_for_for_loop<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
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)
@ -2695,7 +2695,7 @@ fn check_method_argument_types<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
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,
@ -2743,7 +2743,7 @@ fn check_argument_types<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
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,
@ -2834,7 +2834,7 @@ fn check_argument_types<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
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 => (),
_ => {
@ -2866,7 +2866,7 @@ fn check_argument_types<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
// 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| {
@ -3298,7 +3298,7 @@ fn check_expr_with_unifier<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
// 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);
@ -3700,7 +3700,7 @@ fn check_expr_with_unifier<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
// 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);
@ -3761,7 +3761,7 @@ fn check_expr_with_unifier<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
// 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 {
@ -4092,7 +4092,7 @@ fn check_expr_with_unifier<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
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
@ -4121,7 +4121,7 @@ fn check_expr_with_unifier<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
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);
@ -4387,7 +4387,7 @@ fn check_expr_with_unifier<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
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
}
@ -4419,7 +4419,7 @@ fn check_expr_with_unifier<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
let uty = match expected {
ExpectHasType(uty) => {
match ty::get(uty).sty {
match uty.sty {
ty::ty_vec(ty, _) => Some(ty),
_ => None
}
@ -4510,7 +4510,7 @@ fn check_expr_with_unifier<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
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,
@ -4733,7 +4733,7 @@ impl<'tcx> Expectation<'tcx> {
-> Expectation<'tcx> {
match self.resolve(fcx) {
NoExpectation => NoExpectation,
ExpectCastableToType(t) | ExpectHasType(t) => unpack(&ty::get(t).sty),
ExpectCastableToType(t) | ExpectHasType(t) => unpack(&t.sty),
}
}
@ -4744,7 +4744,7 @@ impl<'tcx> Expectation<'tcx> {
{
match self.resolve(fcx) {
NoExpectation => None,
ExpectCastableToType(t) | ExpectHasType(t) => unpack(&ty::get(t).sty),
ExpectCastableToType(t) | ExpectHasType(t) => unpack(&t.sty),
}
}
}
@ -5042,7 +5042,7 @@ pub fn check_simd(tcx: &ty::ctxt, sp: Span, id: ast::NodeId) {
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() {
@ -5750,7 +5750,7 @@ pub fn structurally_resolved_type<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, sp: Span,
// 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
@ -5789,7 +5789,7 @@ pub fn check_bounds_are_used<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
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;

View File

@ -693,7 +693,7 @@ fn visit_expr(rcx: &mut Rcx, expr: &ast::Expr) {
}
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);
@ -814,7 +814,7 @@ fn constrain_cast(rcx: &mut Rcx,
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.
@ -846,7 +846,7 @@ fn check_expr_fn_block(rcx: &mut Rcx,
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,
..}) => {
@ -889,7 +889,7 @@ fn check_expr_fn_block(rcx: &mut Rcx,
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);
@ -905,7 +905,7 @@ fn check_expr_fn_block(rcx: &mut Rcx,
_ => {}
}
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);
@ -1092,7 +1092,7 @@ fn constrain_callee(rcx: &mut Rcx,
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 {
@ -1204,7 +1204,7 @@ fn constrain_autoderefs<'a, 'tcx>(rcx: &mut Rcx<'a, 'tcx>,
// 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 {}",
@ -1232,7 +1232,7 @@ fn constrain_autoderefs<'a, 'tcx>(rcx: &mut Rcx<'a, 'tcx>,
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);
@ -1272,8 +1272,8 @@ fn constrain_index<'a, 'tcx>(rcx: &mut Rcx<'a, 'tcx>,
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);

View File

@ -59,7 +59,7 @@ impl<'a, 'tcx> Wf<'a, 'tcx> {
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(..) |

View File

@ -39,7 +39,7 @@ pub fn check_object_cast<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
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);
@ -97,7 +97,7 @@ pub fn check_object_cast<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
}
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")
}

View File

@ -193,7 +193,7 @@ impl<'ccx, 'tcx> CheckTypeWellFormedVisitor<'ccx, 'tcx> {
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);
@ -336,7 +336,7 @@ impl<'cx,'tcx> TypeFolder<'tcx> for BoundsChecker<'cx,'tcx> {
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);

View File

@ -20,7 +20,6 @@ use metadata::csearch::{each_impl, get_impl_trait};
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};
@ -71,7 +70,7 @@ fn get_base_type<'a, 'tcx>(inference_context: &InferCtxt<'a, 'tcx>,
}
};
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)
@ -87,7 +86,7 @@ fn get_base_type<'a, 'tcx>(inference_context: &InferCtxt<'a, 'tcx>,
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")
@ -102,7 +101,7 @@ fn get_base_type_def_id<'a, 'tcx>(inference_context: &InferCtxt<'a, 'tcx>,
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, _, _) => {
@ -111,7 +110,7 @@ fn get_base_type_def_id<'a, 'tcx>(inference_context: &InferCtxt<'a, 'tcx>,
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)
}
@ -442,7 +441,7 @@ impl<'a, 'tcx> CoherenceChecker<'a, 'tcx> {
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, _, _) => {

View File

@ -51,7 +51,7 @@ impl<'cx, 'tcx,'v> visit::Visitor<'v> for OrphanChecker<'cx, 'tcx> {
// 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);

View File

@ -663,7 +663,7 @@ fn is_associated_type_valid_for_param(ty: Ty,
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);
@ -694,7 +694,7 @@ fn find_associated_type_in_generics<'tcx>(tcx: &ty::ctxt<'tcx>,
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);
@ -722,7 +722,7 @@ fn find_associated_type_in_generics<'tcx>(tcx: &ty::ctxt<'tcx>,
}
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,
}
@ -1908,7 +1908,7 @@ fn get_or_create_type_parameter_def<'tcx,AC>(this: &AC,
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 \
@ -2150,7 +2150,7 @@ fn check_method_self_type<'a, 'tcx, RS:RegionScope>(
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,

View File

@ -105,9 +105,9 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
//
// 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)
@ -134,7 +134,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
}
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)
@ -202,7 +202,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
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(
@ -273,7 +273,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
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| {
@ -472,7 +472,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
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`?

View File

@ -329,8 +329,8 @@ pub fn super_tys<'tcx, C: Combine<'tcx>>(this: &C,
-> 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:
@ -387,7 +387,7 @@ pub fn super_tys<'tcx, C: Combine<'tcx>>(this: &C,
(&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)))
@ -449,7 +449,7 @@ pub fn super_tys<'tcx, C: Combine<'tcx>>(this: &C,
// 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 }
@ -692,7 +692,7 @@ impl<'cx, 'tcx> ty_fold::TypeFolder<'tcx> for Generalizer<'cx, 'tcx> {
//
// (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;

View File

@ -111,7 +111,7 @@ impl<'f, 'tcx> Combine<'tcx> for Equate<'f, 'tcx> {
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)

View File

@ -80,7 +80,7 @@ pub fn super_lattice_tys<'tcx, L:LatticeDir<'tcx>+Combine<'tcx>>(this: &L,
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();

View File

@ -528,7 +528,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
}
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
}
@ -838,7 +838,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
}
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)
@ -878,7 +878,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
(*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()
}

View File

@ -159,7 +159,7 @@ impl<'a, 'tcx> ResolveState<'a, 'tcx> {
return typ;
}
match ty::get(typ).sty {
match typ.sty {
ty::ty_infer(TyVar(vid)) => {
self.resolve_ty_var(vid)
}

View File

@ -113,7 +113,7 @@ impl<'a, 'tcx> TypeFolder<'tcx> for TypeSkolemizer<'a, 'tcx> {
}
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),

View File

@ -127,7 +127,7 @@ impl<'f, 'tcx> Combine<'tcx> for Sub<'f, 'tcx> {
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()

View File

@ -133,7 +133,7 @@ impl<'tcx> TypeVariableTable<'tcx> {
}
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,

View File

@ -363,7 +363,7 @@ fn check_main_fn_ty(ccx: &CrateCtxt,
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)) => {
@ -410,7 +410,7 @@ fn check_start_fn_ty(ccx: &CrateCtxt,
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)) => {

View File

@ -729,7 +729,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
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 => {

View File

@ -1300,9 +1300,7 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DxrVisitor<'l, 'tcx> {
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() {
@ -1328,9 +1326,7 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DxrVisitor<'l, 'tcx> {
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() {

View File

@ -811,10 +811,10 @@ fn compare_values<'blk, 'tcx>(cx: Block<'blk, 'tcx>,
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().
@ -1034,7 +1034,7 @@ fn compile_submatch_continue<'a, 'p, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
} 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)

View File

@ -166,7 +166,7 @@ pub fn represent_type<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
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)
}
@ -306,9 +306,9 @@ impl<'tcx> Case<'tcx> {
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)),

View File

@ -266,7 +266,7 @@ pub fn kind_for_unboxed_closure(ccx: &CrateContext, closure_id: ast::DefId)
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)
}
@ -561,7 +561,7 @@ pub fn compare_scalar_types<'blk, 'tcx>(cx: Block<'blk, 'tcx>,
-> 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),
@ -642,7 +642,7 @@ pub fn compare_simd_types<'blk, 'tcx>(
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
@ -711,7 +711,7 @@ pub fn iter_structural_ty<'a, 'blk, 'tcx>(cx: Block<'blk, 'tcx>,
};
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| {
@ -871,7 +871,7 @@ pub fn fail_if_zero_or_overflows<'blk, 'tcx>(
("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)
@ -899,7 +899,7 @@ pub fn fail_if_zero_or_overflows<'blk, 'tcx>(
// 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 {
@ -932,7 +932,7 @@ pub fn fail_if_zero_or_overflows<'blk, 'tcx>(
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 => {
@ -1564,7 +1564,7 @@ fn create_datums_for_fn_args_under_call_abi<'blk, 'tcx>(
}
// 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 =
@ -1661,7 +1661,7 @@ fn copy_unboxed_closure_args_to_allocas<'blk, 'tcx>(
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,
@ -1978,7 +1978,7 @@ pub fn trans_named_tuple_constructor<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
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: \
@ -2050,7 +2050,7 @@ fn trans_enum_variant_or_tuple_like_struct<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx
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: \
@ -2387,7 +2387,7 @@ fn register_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
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);
}
@ -2403,7 +2403,7 @@ pub fn get_fn_llvm_attributes<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, fn_ty: Ty<
-> 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) => {
@ -2425,11 +2425,11 @@ pub fn get_fn_llvm_attributes<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, fn_ty: Ty<
// 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")
}
@ -2437,7 +2437,7 @@ pub fn get_fn_llvm_attributes<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, fn_ty: Ty<
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
@ -2469,7 +2469,7 @@ pub fn get_fn_llvm_attributes<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, fn_ty: Ty<
} 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) => {}
@ -2480,7 +2480,7 @@ pub fn get_fn_llvm_attributes<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, fn_ty: Ty<
}
// 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) => {}
@ -2491,7 +2491,7 @@ pub fn get_fn_llvm_attributes<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, fn_ty: Ty<
_ => {}
}
match ty::get(ret_ty).sty {
match ret_ty.sty {
ty::ty_bool => {
attrs.ret(llvm::ZExtAttribute);
}
@ -2501,7 +2501,7 @@ pub fn get_fn_llvm_attributes<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, fn_ty: Ty<
}
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));

View File

@ -107,7 +107,7 @@ fn trans<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, expr: &ast::Expr)
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 {
@ -163,7 +163,7 @@ fn trans<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, expr: &ast::Expr)
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
} => {
@ -707,7 +707,7 @@ pub fn trans_call_inner<'a, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
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")
@ -933,7 +933,7 @@ fn trans_args_under_call_abi<'blk, 'tcx>(
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));
@ -991,7 +991,7 @@ fn trans_overloaded_call_args<'blk, 'tcx>(
// 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 =

View File

@ -15,7 +15,6 @@ use back::link::mangle_internal_name_by_path_and_seq;
use llvm::ValueRef;
use middle::def;
use middle::mem_categorization::Typer;
use middle::subst::Substs;
use trans::adt;
use trans::base::*;
use trans::build::*;
@ -470,7 +469,7 @@ pub fn get_or_create_declaration_if_unboxed_closure<'blk, 'tcx>(bcx: Block<'blk,
// 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!()
};
@ -605,7 +604,7 @@ pub fn get_wrapper_for_bare_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
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: \

View File

@ -57,7 +57,7 @@ pub use trans::context::CrateContext;
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 &&
@ -84,7 +84,7 @@ pub fn type_is_immediate<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, ty: Ty<'tcx>) -
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);

View File

@ -52,7 +52,7 @@ pub fn const_lit(cx: &CrateContext, e: &ast::Expr, lit: &ast::Lit)
}
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)
}
@ -70,7 +70,7 @@ pub fn const_lit(cx: &CrateContext, e: &ast::Expr, lit: &ast::Lit)
}
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))
}
@ -144,7 +144,7 @@ fn const_deref<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, v: ValueRef,
-> (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)
@ -260,7 +260,7 @@ pub fn const_expr<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, e: &ast::Expr)
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);
@ -442,9 +442,9 @@ fn const_expr_unadjusted(cx: &CrateContext, e: &ast::Expr) -> ValueRef {
_ => 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]))
@ -454,7 +454,7 @@ fn const_expr_unadjusted(cx: &CrateContext, e: &ast::Expr) -> ValueRef {
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))
},
@ -470,8 +470,8 @@ fn const_expr_unadjusted(cx: &CrateContext, e: &ast::Expr) -> ValueRef {
};
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

View File

@ -518,7 +518,7 @@ impl<'tcx> Datum<'tcx, Lvalue> {
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));

View File

@ -357,7 +357,7 @@ impl<'tcx> TypeMap<'tcx> {
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 |
@ -485,7 +485,7 @@ impl<'tcx> TypeMap<'tcx> {
_ => {
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())
}
};
@ -1743,9 +1743,9 @@ fn diverging_type_metadata(cx: &CrateContext) -> DIType {
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),
@ -2787,7 +2787,7 @@ fn subroutine_type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
// 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)
},
@ -2826,7 +2826,7 @@ fn trait_pointer_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
// 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);
@ -2891,9 +2891,9 @@ fn type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
}
};
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 |
@ -2920,7 +2920,7 @@ fn type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
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)
}
@ -3688,7 +3688,7 @@ fn push_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
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"),

View File

@ -212,7 +212,7 @@ fn apply_adjustments<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
// 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);
@ -318,7 +318,7 @@ fn apply_adjustments<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
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
@ -446,7 +446,7 @@ fn apply_adjustments<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
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())
@ -628,7 +628,7 @@ fn trans_datum_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
// 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)
}
@ -1173,7 +1173,7 @@ fn trans_def_dps_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
}
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);
@ -1276,7 +1276,7 @@ pub fn with_field_tys<'tcx, R>(tcx: &ty::ctxt<'tcx>,
* 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())
}
@ -1605,7 +1605,7 @@ fn trans_addr_of<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
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));
@ -1906,7 +1906,7 @@ pub enum cast_kind {
}
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) => {
@ -2139,7 +2139,7 @@ fn deref_once<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
}
};
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)

View File

@ -122,7 +122,7 @@ pub fn register_static(ccx: &CrateContext,
"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,
@ -235,7 +235,7 @@ pub fn trans_native_call<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
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")
};
@ -490,7 +490,7 @@ pub fn decl_rust_fn_with_foreign_abi<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
-> 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)
}
@ -513,7 +513,7 @@ pub fn register_rust_fn_with_foreign_abi(ccx: &CrateContext,
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)
}
@ -567,7 +567,7 @@ pub fn trans_rust_fn_with_foreign_abi<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
// 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);
}
@ -864,7 +864,7 @@ fn foreign_types_for_id<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
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")
};

View File

@ -87,7 +87,7 @@ pub fn get_drop_glue_type<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
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);
@ -225,7 +225,7 @@ fn trans_struct_drop<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
};
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]
@ -308,7 +308,7 @@ fn size_and_align_of_dst<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, t: Ty<'tcx>, info:
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.
@ -358,9 +358,9 @@ fn make_drop_glue<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, v0: ValueRef, t: Ty<'tcx>)
-> 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)
}

View File

@ -149,7 +149,7 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
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")
};

View File

@ -488,7 +488,7 @@ pub fn trans_trait_callee_from_llval<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
// 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)),
@ -585,12 +585,10 @@ pub fn get_vtable<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
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));

View File

@ -420,15 +420,15 @@ pub fn get_base_and_len(bcx: Block,
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]);

View File

@ -81,7 +81,7 @@ pub fn untuple_arguments_if_necessary<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
}
}
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() {
@ -142,7 +142,7 @@ pub fn type_of_rust_fn<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
// 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)),
@ -184,7 +184,7 @@ pub fn sizing_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> Typ
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())
@ -269,7 +269,7 @@ pub fn type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> Type {
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 : {}",
@ -283,7 +283,7 @@ pub fn type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> 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
@ -304,7 +304,7 @@ pub fn type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> Type {
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),
@ -333,7 +333,7 @@ pub fn type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> Type {
}
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).
@ -393,7 +393,7 @@ pub fn type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> Type {
}
}
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)
@ -424,7 +424,7 @@ pub fn type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> Type {
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);

View File

@ -169,7 +169,7 @@ pub fn build_external_trait(cx: &DocContext, tcx: &ty::ctxt,
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"),
};
@ -201,7 +201,7 @@ fn build_struct(cx: &DocContext, tcx: &ty::ctxt, did: ast::DefId) -> clean::Stru
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),

View File

@ -1049,7 +1049,7 @@ impl Clean<Item> for ty::Method {
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))
}
@ -1259,7 +1259,7 @@ impl Clean<Type> for ast::Ty {
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),
@ -1321,7 +1321,7 @@ impl Clean<Type> for Ty {
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,