use middle::ty;
use middle::ty::adjustment;
-use rustc_front::hir;
+use rustc_front::hir::{self, PatKind};
use syntax::ast;
use syntax::ptr::P;
ty::ReScope(fn_body_scope), // Args live only as long as the fn body.
arg_ty);
- self.walk_irrefutable_pat(arg_cmt, &*arg.pat);
+ self.walk_irrefutable_pat(arg_cmt, &arg.pat);
}
}
fn consume_exprs(&mut self, exprs: &[P<hir::Expr>]) {
for expr in exprs {
- self.consume_expr(&**expr);
+ self.consume_expr(&expr);
}
}
hir::ExprPath(..) => { }
hir::ExprType(ref subexpr, _) => {
- self.walk_expr(&**subexpr)
+ self.walk_expr(&subexpr)
}
hir::ExprUnary(hir::UnDeref, ref base) => { // *base
- if !self.walk_overloaded_operator(expr, &**base, Vec::new(), PassArgs::ByRef) {
- self.select_from_expr(&**base);
+ if !self.walk_overloaded_operator(expr, &base, Vec::new(), PassArgs::ByRef) {
+ self.select_from_expr(&base);
}
}
hir::ExprField(ref base, _) => { // base.f
- self.select_from_expr(&**base);
+ self.select_from_expr(&base);
}
hir::ExprTupField(ref base, _) => { // base.<n>
- self.select_from_expr(&**base);
+ self.select_from_expr(&base);
}
hir::ExprIndex(ref lhs, ref rhs) => { // lhs[rhs]
if !self.walk_overloaded_operator(expr,
- &**lhs,
- vec![&**rhs],
+ &lhs,
+ vec![&rhs],
PassArgs::ByValue) {
- self.select_from_expr(&**lhs);
- self.consume_expr(&**rhs);
+ self.select_from_expr(&lhs);
+ self.consume_expr(&rhs);
}
}
- hir::ExprRange(ref start, ref end) => {
- start.as_ref().map(|e| self.consume_expr(&**e));
- end.as_ref().map(|e| self.consume_expr(&**e));
- }
-
hir::ExprCall(ref callee, ref args) => { // callee(args)
- self.walk_callee(expr, &**callee);
+ self.walk_callee(expr, &callee);
self.consume_exprs(args);
}
}
hir::ExprIf(ref cond_expr, ref then_blk, ref opt_else_expr) => {
- self.consume_expr(&**cond_expr);
- self.walk_block(&**then_blk);
+ self.consume_expr(&cond_expr);
+ self.walk_block(&then_blk);
if let Some(ref else_expr) = *opt_else_expr {
- self.consume_expr(&**else_expr);
+ self.consume_expr(&else_expr);
}
}
hir::ExprMatch(ref discr, ref arms, _) => {
- let discr_cmt = return_if_err!(self.mc.cat_expr(&**discr));
- self.borrow_expr(&**discr, ty::ReEmpty, ty::ImmBorrow, MatchDiscriminant);
+ let discr_cmt = return_if_err!(self.mc.cat_expr(&discr));
+ self.borrow_expr(&discr, ty::ReEmpty, ty::ImmBorrow, MatchDiscriminant);
// treatment of the discriminant is handled while walking the arms.
for arm in arms {
let expr_ty = return_if_err!(self.typer.node_ty(expr.id));
if let ty::TyRef(&r, _) = expr_ty.sty {
let bk = ty::BorrowKind::from_mutbl(m);
- self.borrow_expr(&**base, r, bk, AddrOf);
+ self.borrow_expr(&base, r, bk, AddrOf);
}
}
hir::ExprInlineAsm(ref ia) => {
for &(_, ref input) in &ia.inputs {
- self.consume_expr(&**input);
+ self.consume_expr(&input);
}
for output in &ia.outputs {
if output.is_indirect {
- self.consume_expr(&*output.expr);
+ self.consume_expr(&output.expr);
} else {
- self.mutate_expr(expr, &*output.expr,
+ self.mutate_expr(expr, &output.expr,
if output.is_rw {
MutateMode::WriteAndRead
} else {
hir::ExprLit(..) => {}
hir::ExprLoop(ref blk, _) => {
- self.walk_block(&**blk);
+ self.walk_block(&blk);
}
hir::ExprWhile(ref cond_expr, ref blk, _) => {
- self.consume_expr(&**cond_expr);
- self.walk_block(&**blk);
+ self.consume_expr(&cond_expr);
+ self.walk_block(&blk);
}
hir::ExprUnary(op, ref lhs) => {
PassArgs::ByRef
};
- if !self.walk_overloaded_operator(expr, &**lhs, Vec::new(), pass_args) {
- self.consume_expr(&**lhs);
+ if !self.walk_overloaded_operator(expr, &lhs, Vec::new(), pass_args) {
+ self.consume_expr(&lhs);
}
}
PassArgs::ByRef
};
- if !self.walk_overloaded_operator(expr, &**lhs, vec![&**rhs], pass_args) {
- self.consume_expr(&**lhs);
- self.consume_expr(&**rhs);
+ if !self.walk_overloaded_operator(expr, &lhs, vec![&rhs], pass_args) {
+ self.consume_expr(&lhs);
+ self.consume_expr(&rhs);
}
}
hir::ExprBlock(ref blk) => {
- self.walk_block(&**blk);
+ self.walk_block(&blk);
}
hir::ExprRet(ref opt_expr) => {
if let Some(ref expr) = *opt_expr {
- self.consume_expr(&**expr);
+ self.consume_expr(&expr);
}
}
hir::ExprAssign(ref lhs, ref rhs) => {
- self.mutate_expr(expr, &**lhs, MutateMode::JustWrite);
- self.consume_expr(&**rhs);
+ self.mutate_expr(expr, &lhs, MutateMode::JustWrite);
+ self.consume_expr(&rhs);
}
hir::ExprCast(ref base, _) => {
- self.consume_expr(&**base);
+ self.consume_expr(&base);
}
hir::ExprAssignOp(op, ref lhs, ref rhs) => {
assert!(::rustc_front::util::is_by_value_binop(op.node));
if !self.walk_overloaded_operator(expr, lhs, vec![rhs], PassArgs::ByValue) {
- self.mutate_expr(expr, &**lhs, MutateMode::WriteAndRead);
- self.consume_expr(&**rhs);
+ self.mutate_expr(expr, &lhs, MutateMode::WriteAndRead);
+ self.consume_expr(&rhs);
}
}
hir::ExprRepeat(ref base, ref count) => {
- self.consume_expr(&**base);
- self.consume_expr(&**count);
+ self.consume_expr(&base);
+ self.consume_expr(&count);
}
hir::ExprClosure(..) => {
}
hir::ExprBox(ref base) => {
- self.consume_expr(&**base);
+ self.consume_expr(&base);
}
}
}
hir::StmtDecl(ref decl, _) => {
match decl.node {
hir::DeclLocal(ref local) => {
- self.walk_local(&**local);
+ self.walk_local(&local);
}
hir::DeclItem(_) => {
hir::StmtExpr(ref expr, _) |
hir::StmtSemi(ref expr, _) => {
- self.consume_expr(&**expr);
+ self.consume_expr(&expr);
}
}
}
match local.init {
None => {
let delegate = &mut self.delegate;
- pat_util::pat_bindings(&self.typer.tcx.def_map, &*local.pat,
+ pat_util::pat_bindings(&self.typer.tcx.def_map, &local.pat,
|_, id, span, _| {
delegate.decl_without_init(id, span);
})
// initializers are considered
// "assigns", which is handled by
// `walk_pat`:
- self.walk_expr(&**expr);
- let init_cmt = return_if_err!(self.mc.cat_expr(&**expr));
- self.walk_irrefutable_pat(init_cmt, &*local.pat);
+ self.walk_expr(&expr);
+ let init_cmt = return_if_err!(self.mc.cat_expr(&expr));
+ self.walk_irrefutable_pat(init_cmt, &local.pat);
}
}
}
}
if let Some(ref tail_expr) = blk.expr {
- self.consume_expr(&**tail_expr);
+ self.consume_expr(&tail_expr);
}
}
opt_with: &Option<P<hir::Expr>>) {
// Consume the expressions supplying values for each field.
for field in fields {
- self.consume_expr(&*field.expr);
+ self.consume_expr(&field.expr);
}
let with_expr = match *opt_with {
None => { return; }
};
- let with_cmt = return_if_err!(self.mc.cat_expr(&*with_expr));
+ let with_cmt = return_if_err!(self.mc.cat_expr(&with_expr));
// Select just those fields of the `with`
// expression that will actually be used
if let Some(adjustment) = adj {
match adjustment {
adjustment::AdjustReifyFnPointer |
- adjustment::AdjustUnsafeFnPointer => {
+ adjustment::AdjustUnsafeFnPointer |
+ adjustment::AdjustMutToConstPointer => {
// Creating a closure/fn-pointer or unsizing consumes
// the input and stores it into the resulting rvalue.
- debug!("walk_adjustment(AdjustReifyFnPointer|AdjustUnsafeFnPointer)");
+ debug!("walk_adjustment: trivial adjustment");
let cmt_unadjusted =
return_if_err!(self.mc.cat_expr_unadjusted(expr));
self.delegate_consume(expr.id, expr.span, cmt_unadjusted);
fn arm_move_mode(&mut self, discr_cmt: mc::cmt<'tcx>, arm: &hir::Arm) -> TrackMatchMode {
let mut mode = Unknown;
for pat in &arm.pats {
- self.determine_pat_move_mode(discr_cmt.clone(), &**pat, &mut mode);
+ self.determine_pat_move_mode(discr_cmt.clone(), &pat, &mut mode);
}
mode
}
fn walk_arm(&mut self, discr_cmt: mc::cmt<'tcx>, arm: &hir::Arm, mode: MatchMode) {
for pat in &arm.pats {
- self.walk_pat(discr_cmt.clone(), &**pat, mode);
+ self.walk_pat(discr_cmt.clone(), &pat, mode);
}
if let Some(ref guard) = arm.guard {
- self.consume_expr(&**guard);
+ self.consume_expr(&guard);
}
- self.consume_expr(&*arm.body);
+ self.consume_expr(&arm.body);
}
/// Walks a pat that occurs in isolation (i.e. top-level of fn
let def_map = &self.tcx().def_map;
if pat_util::pat_is_binding(&def_map.borrow(), pat) {
match pat.node {
- hir::PatIdent(hir::BindByRef(_), _, _) =>
+ PatKind::Ident(hir::BindByRef(_), _, _) =>
mode.lub(BorrowingMatch),
- hir::PatIdent(hir::BindByValue(_), _, _) => {
+ PatKind::Ident(hir::BindByValue(_), _, _) => {
match copy_or_move(self.typer, &cmt_pat, PatBindingMove) {
Copy => mode.lub(CopyingMatch),
Move(_) => mode.lub(MovingMatch),
// It is also a borrow or copy/move of the value being matched.
match pat.node {
- hir::PatIdent(hir::BindByRef(m), _, _) => {
+ PatKind::Ident(hir::BindByRef(m), _, _) => {
if let ty::TyRef(&r, _) = pat_ty.sty {
let bk = ty::BorrowKind::from_mutbl(m);
delegate.borrow(pat.id, pat.span, cmt_pat,
r, bk, RefBinding);
}
}
- hir::PatIdent(hir::BindByValue(_), _, _) => {
+ PatKind::Ident(hir::BindByValue(_), _, _) => {
let mode = copy_or_move(typer, &cmt_pat, PatBindingMove);
debug!("walk_pat binding consuming pat");
delegate.consume_pat(pat, cmt_pat, mode);
}
} else {
match pat.node {
- hir::PatVec(_, Some(ref slice_pat), _) => {
+ PatKind::Vec(_, Some(ref slice_pat), _) => {
// The `slice_pat` here creates a slice into
// the original vector. This is effectively a
// borrow of the elements of the vector being
// matched.
let (slice_cmt, slice_mutbl, slice_r) =
- return_if_err!(mc.cat_slice_pattern(cmt_pat, &**slice_pat));
+ return_if_err!(mc.cat_slice_pattern(cmt_pat, &slice_pat));
// Note: We declare here that the borrow
// occurs upon entering the `[...]`
let tcx = typer.tcx;
match pat.node {
- hir::PatEnum(_, _) | hir::PatQPath(..) |
- hir::PatIdent(_, _, None) | hir::PatStruct(..) => {
+ PatKind::TupleStruct(..) | PatKind::Path(..) | PatKind::QPath(..) |
+ PatKind::Ident(_, _, None) | PatKind::Struct(..) => {
match def_map.get(&pat.id).map(|d| d.full_def()) {
None => {
// no definition found: pat is not a
}
}
- hir::PatIdent(_, _, Some(_)) => {
+ PatKind::Ident(_, _, Some(_)) => {
// Do nothing; this is a binding (not an enum
// variant or struct), and the cat_pattern call
// will visit the substructure recursively.
}
- hir::PatWild | hir::PatTup(..) | hir::PatBox(..) |
- hir::PatRegion(..) | hir::PatLit(..) | hir::PatRange(..) |
- hir::PatVec(..) => {
+ PatKind::Wild | PatKind::Tup(..) | PatKind::Box(..) |
+ PatKind::Ref(..) | PatKind::Lit(..) | PatKind::Range(..) |
+ PatKind::Vec(..) => {
// Similarly, each of these cases does not
// correspond to an enum variant or struct, so we
// do not do any `matched_pat` calls for these