Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
rustc: middle: remove obsolete ty::get.
  • Loading branch information
eddyb committed Nov 19, 2014
1 parent 01105ff commit 9f7aa7f
Show file tree
Hide file tree
Showing 65 changed files with 326 additions and 346 deletions.
16 changes: 8 additions & 8 deletions src/librustc/lint/builtin.rs
Expand Up @@ -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");
}
}
Expand Down Expand Up @@ -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 \
Expand All @@ -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
Expand All @@ -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)) |
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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, _) |
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/metadata/decoder.rs
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/metadata/tyencode.rs
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/borrowck/gather_loans/gather_moves.rs
Expand Up @@ -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())
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/borrowck/gather_loans/move_error.rs
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/borrowck/mod.rs
Expand Up @@ -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(..),
..
Expand Down
14 changes: 7 additions & 7 deletions src/librustc/middle/check_match.rs
Expand Up @@ -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, _) => {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/check_static.rs
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/const_eval.rs
Expand Up @@ -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)),
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/dead.rs
Expand Up @@ -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()
Expand All @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions src/librustc/middle/effect.rs
Expand Up @@ -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,
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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")
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/middle/expr_use_visitor.rs
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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 {}",
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/fast_reject.rs
Expand Up @@ -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)),
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/middle/intrinsicck.rs
Expand Up @@ -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
Expand Down Expand Up @@ -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
};
Expand Down Expand Up @@ -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 {
Expand Down
5 changes: 2 additions & 3 deletions src/librustc/middle/liveness.rs
Expand Up @@ -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()
Expand Down Expand Up @@ -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
},
Expand Down
14 changes: 7 additions & 7 deletions src/librustc/middle/mem_categorization.rs
Expand Up @@ -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))
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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),
},
Expand Down Expand Up @@ -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
},
Expand Down

0 comments on commit 9f7aa7f

Please sign in to comment.