let tcx = self.tcx;
let param_env = self.param_env;
let region_scope_tree = self.tcx.region_scope_tree(item_def_id);
- euv::ExprUseVisitor::new(self, tcx, param_env, ®ion_scope_tree, self.tables, None)
+ let tables = self.tables;
+ euv::ExprUseVisitor::new(self, tcx, param_env, ®ion_scope_tree, tables, None)
.consume_body(body);
let body_promotable = self.check_expr(&body.value);
fn check_stmt(&mut self, stmt: &'tcx hir::Stmt) -> Promotability {
match stmt.node {
- hir::StmtDecl(ref decl, _node_id) => {
+ hir::StmtKind::Decl(ref decl, _node_id) => {
match &decl.node {
- hir::DeclLocal(local) => {
+ hir::DeclKind::Local(local) => {
if self.remove_mut_rvalue_borrow(&local.pat) {
if let Some(init) = &local.init {
self.mut_rvalue_borrows.insert(init.id);
NotPromotable
}
// Item statements are allowed
- hir::DeclItem(_) => Promotable
+ hir::DeclKind::Item(_) => Promotable
}
}
- hir::StmtExpr(ref box_expr, _node_id) |
- hir::StmtSemi(ref box_expr, _node_id) => {
+ hir::StmtKind::Expr(ref box_expr, _node_id) |
+ hir::StmtKind::Semi(ref box_expr, _node_id) => {
let _ = self.check_expr(box_expr);
NotPromotable
}
e: &'tcx hir::Expr, node_ty: Ty<'tcx>) -> Promotability {
let ty_result = match node_ty.sty {
- ty::TyAdt(def, _) if def.has_dtor(v.tcx) => {
+ ty::Adt(def, _) if def.has_dtor(v.tcx) => {
NotPromotable
}
_ => Promotable
};
let node_result = match e.node {
- hir::ExprBox(ref expr) => {
+ hir::ExprKind::Box(ref expr) => {
let _ = v.check_expr(&expr);
NotPromotable
}
- hir::ExprUnary(op, ref expr) => {
+ hir::ExprKind::Unary(op, ref expr) => {
let expr_promotability = v.check_expr(expr);
if v.tables.is_method_call(e) {
return NotPromotable;
}
expr_promotability
}
- hir::ExprBinary(op, ref lhs, ref rhs) => {
+ hir::ExprKind::Binary(op, ref lhs, ref rhs) => {
let lefty = v.check_expr(lhs);
let righty = v.check_expr(rhs);
if v.tables.is_method_call(e) {
return NotPromotable;
}
match v.tables.node_id_to_type(lhs.hir_id).sty {
- ty::TyRawPtr(_) => {
- assert!(op.node == hir::BiEq || op.node == hir::BiNe ||
- op.node == hir::BiLe || op.node == hir::BiLt ||
- op.node == hir::BiGe || op.node == hir::BiGt);
+ ty::RawPtr(_) => {
+ assert!(op.node == hir::BinOpKind::Eq || op.node == hir::BinOpKind::Ne ||
+ op.node == hir::BinOpKind::Le || op.node == hir::BinOpKind::Lt ||
+ op.node == hir::BinOpKind::Ge || op.node == hir::BinOpKind::Gt);
NotPromotable
}
_ => lefty & righty
}
}
- hir::ExprCast(ref from, _) => {
+ hir::ExprKind::Cast(ref from, _) => {
let expr_promotability = v.check_expr(from);
debug!("Checking const cast(id={})", from.id);
match v.tables.cast_kinds().get(from.hir_id) {
_ => expr_promotability
}
}
- hir::ExprPath(ref qpath) => {
+ hir::ExprKind::Path(ref qpath) => {
let def = v.tables.qpath_def(qpath, e.hir_id);
match def {
Def::VariantCtor(..) | Def::StructCtor(..) |
_ => NotPromotable
}
}
- hir::ExprCall(ref callee, ref hirvec) => {
+ hir::ExprKind::Call(ref callee, ref hirvec) => {
let mut call_result = v.check_expr(callee);
for index in hirvec.iter() {
call_result = call_result & v.check_expr(index);
let mut callee = &**callee;
loop {
callee = match callee.node {
- hir::ExprBlock(ref block, _) => match block.expr {
+ hir::ExprKind::Block(ref block, _) => match block.expr {
Some(ref tail) => &tail,
None => break
},
};
}
// The callee is an arbitrary expression, it doesn't necessarily have a definition.
- let def = if let hir::ExprPath(ref qpath) = callee.node {
+ let def = if let hir::ExprKind::Path(ref qpath) = callee.node {
v.tables.qpath_def(qpath, callee.hir_id)
} else {
Def::Err
};
def_result & call_result
}
- hir::ExprMethodCall(ref _pathsegment, ref _span, ref hirvec) => {
+ hir::ExprKind::MethodCall(ref _pathsegment, ref _span, ref hirvec) => {
let mut method_call_result = Promotable;
for index in hirvec.iter() {
method_call_result = method_call_result & v.check_expr(index);
}
method_call_result
}
- hir::ExprStruct(ref _qpath, ref hirvec, ref option_expr) => {
+ hir::ExprKind::Struct(ref _qpath, ref hirvec, ref option_expr) => {
let mut struct_result = Promotable;
for index in hirvec.iter() {
struct_result = struct_result & v.check_expr(&index.expr);
Some(ref expr) => { struct_result = struct_result & v.check_expr(&expr); },
None => {},
}
- if let ty::TyAdt(adt, ..) = v.tables.expr_ty(e).sty {
+ if let ty::Adt(adt, ..) = v.tables.expr_ty(e).sty {
// unsafe_cell_type doesn't necessarily exist with no_core
if Some(adt.did) == v.tcx.lang_items().unsafe_cell_type() {
return NotPromotable;
struct_result
}
- hir::ExprLit(_) => Promotable,
+ hir::ExprKind::Lit(_) => Promotable,
- hir::ExprAddrOf(_, ref expr) |
- hir::ExprRepeat(ref expr, _) => {
+ hir::ExprKind::AddrOf(_, ref expr) |
+ hir::ExprKind::Repeat(ref expr, _) => {
v.check_expr(&expr)
}
- hir::ExprClosure(_capture_clause, ref _box_fn_decl,
+ hir::ExprKind::Closure(_capture_clause, ref _box_fn_decl,
body_id, _span, _option_generator_movability) => {
let nested_body_promotable = v.check_nested_body(body_id);
// Paths in constant contexts cannot refer to local variables,
}
}
- hir::ExprField(ref expr, _ident) => {
+ hir::ExprKind::Field(ref expr, _ident) => {
let expr_promotability = v.check_expr(&expr);
if let Some(def) = v.tables.expr_ty(expr).ty_adt_def() {
if def.is_union() {
expr_promotability
}
- hir::ExprBlock(ref box_block, ref _option_label) => {
+ hir::ExprKind::Block(ref box_block, ref _option_label) => {
v.check_block(box_block)
}
- hir::ExprIndex(ref lhs, ref rhs) => {
+ hir::ExprKind::Index(ref lhs, ref rhs) => {
let lefty = v.check_expr(lhs);
let righty = v.check_expr(rhs);
if v.tables.is_method_call(e) {
lefty & righty
}
- hir::ExprArray(ref hirvec) => {
+ hir::ExprKind::Array(ref hirvec) => {
let mut array_result = Promotable;
for index in hirvec.iter() {
array_result = array_result & v.check_expr(index);
array_result
}
- hir::ExprType(ref expr, ref _ty) => {
+ hir::ExprKind::Type(ref expr, ref _ty) => {
v.check_expr(&expr)
}
- hir::ExprTup(ref hirvec) => {
+ hir::ExprKind::Tup(ref hirvec) => {
let mut tup_result = Promotable;
for index in hirvec.iter() {
tup_result = tup_result & v.check_expr(index);
// Conditional control flow (possible to implement).
- hir::ExprMatch(ref expr, ref hirvec_arm, ref _match_source) => {
+ hir::ExprKind::Match(ref expr, ref hirvec_arm, ref _match_source) => {
// Compute the most demanding borrow from all the arms'
// patterns and set that on the discriminator.
let mut mut_borrow = false;
NotPromotable
}
- hir::ExprIf(ref lhs, ref rhs, ref option_expr) => {
+ hir::ExprKind::If(ref lhs, ref rhs, ref option_expr) => {
let _ = v.check_expr(lhs);
let _ = v.check_expr(rhs);
match option_expr {
}
// Loops (not very meaningful in constants).
- hir::ExprWhile(ref expr, ref box_block, ref _option_label) => {
+ hir::ExprKind::While(ref expr, ref box_block, ref _option_label) => {
let _ = v.check_expr(expr);
let _ = v.check_block(box_block);
NotPromotable
}
- hir::ExprLoop(ref box_block, ref _option_label, ref _loop_source) => {
+ hir::ExprKind::Loop(ref box_block, ref _option_label, ref _loop_source) => {
let _ = v.check_block(box_block);
NotPromotable
}
// More control flow (also not very meaningful).
- hir::ExprBreak(_, ref option_expr) | hir::ExprRet(ref option_expr) => {
+ hir::ExprKind::Break(_, ref option_expr) | hir::ExprKind::Ret(ref option_expr) => {
match *option_expr {
Some(ref expr) => { let _ = v.check_expr(&expr); },
None => {},
NotPromotable
}
- hir::ExprContinue(_) => {
+ hir::ExprKind::Continue(_) => {
NotPromotable
}
// Generator expressions
- hir::ExprYield(ref expr) => {
+ hir::ExprKind::Yield(ref expr) => {
let _ = v.check_expr(&expr);
NotPromotable
}
// Expressions with side-effects.
- hir::ExprAssignOp(_, ref lhs, ref rhs) | hir::ExprAssign(ref lhs, ref rhs) => {
+ hir::ExprKind::AssignOp(_, ref lhs, ref rhs) | hir::ExprKind::Assign(ref lhs, ref rhs) => {
let _ = v.check_expr(lhs);
let _ = v.check_expr(rhs);
NotPromotable
}
- hir::ExprInlineAsm(ref _inline_asm, ref hirvec_lhs, ref hirvec_rhs) => {
+ hir::ExprKind::InlineAsm(ref _inline_asm, ref hirvec_lhs, ref hirvec_rhs) => {
for index in hirvec_lhs.iter() {
let _ = v.check_expr(index);
}