Remove hir::ExprParen
This commit is contained in:
parent
70c6fb9193
commit
d21bfff78c
@ -354,7 +354,6 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
|
||||
hir::ExprAddrOf(_, ref e) |
|
||||
hir::ExprCast(ref e, _) |
|
||||
hir::ExprUnary(_, ref e) |
|
||||
hir::ExprParen(ref e) |
|
||||
hir::ExprField(ref e, _) |
|
||||
hir::ExprTupField(ref e, _) => {
|
||||
self.straightline(expr, pred, Some(&**e).into_iter())
|
||||
|
@ -678,7 +678,6 @@ fn check_expr<'a, 'tcx>(v: &mut CheckCrateVisitor<'a, 'tcx>,
|
||||
let mut callee = &**callee;
|
||||
loop {
|
||||
callee = match callee.node {
|
||||
hir::ExprParen(ref inner) => &**inner,
|
||||
hir::ExprBlock(ref block) => match block.expr {
|
||||
Some(ref tail) => &**tail,
|
||||
None => break
|
||||
@ -763,7 +762,6 @@ fn check_expr<'a, 'tcx>(v: &mut CheckCrateVisitor<'a, 'tcx>,
|
||||
hir::ExprField(..) |
|
||||
hir::ExprTupField(..) |
|
||||
hir::ExprVec(_) |
|
||||
hir::ExprParen(..) |
|
||||
hir::ExprTup(..) => {}
|
||||
|
||||
// Conditional control flow (possible to implement).
|
||||
|
@ -996,7 +996,6 @@ pub fn eval_const_expr_partial<'tcx>(tcx: &ty::ctxt<'tcx>,
|
||||
hir::ExprLit(ref lit) => {
|
||||
lit_to_const(&**lit, ety)
|
||||
}
|
||||
hir::ExprParen(ref e) => try!(eval_const_expr_partial(tcx, &**e, ty_hint)),
|
||||
hir::ExprBlock(ref block) => {
|
||||
match block.expr {
|
||||
Some(ref expr) => try!(eval_const_expr_partial(tcx, &**expr, ty_hint)),
|
||||
|
@ -362,9 +362,6 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> {
|
||||
let cmt = return_if_err!(self.mc.cat_expr(expr));
|
||||
self.delegate.borrow(expr.id, expr.span, cmt, r, bk, cause);
|
||||
|
||||
// Note: Unlike consume, we can ignore ExprParen. cat_expr
|
||||
// already skips over them, and walk will uncover any
|
||||
// attachments or whatever.
|
||||
self.walk_expr(expr)
|
||||
}
|
||||
|
||||
@ -378,10 +375,6 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> {
|
||||
self.walk_adjustment(expr);
|
||||
|
||||
match expr.node {
|
||||
hir::ExprParen(ref subexpr) => {
|
||||
self.walk_expr(&**subexpr)
|
||||
}
|
||||
|
||||
hir::ExprPath(..) => { }
|
||||
|
||||
hir::ExprUnary(hir::UnDeref, ref base) => { // *base
|
||||
|
@ -495,7 +495,7 @@ fn visit_expr(ir: &mut IrMaps, expr: &Expr) {
|
||||
hir::ExprAgain(_) | hir::ExprLit(_) | hir::ExprRet(..) |
|
||||
hir::ExprBlock(..) | hir::ExprAssign(..) | hir::ExprAssignOp(..) |
|
||||
hir::ExprStruct(..) | hir::ExprRepeat(..) |
|
||||
hir::ExprParen(..) | hir::ExprInlineAsm(..) | hir::ExprBox(..) |
|
||||
hir::ExprInlineAsm(..) | hir::ExprBox(..) |
|
||||
hir::ExprRange(..) => {
|
||||
visit::walk_expr(ir, expr);
|
||||
}
|
||||
@ -1161,8 +1161,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
|
||||
hir::ExprBox(None, ref e) |
|
||||
hir::ExprAddrOf(_, ref e) |
|
||||
hir::ExprCast(ref e, _) |
|
||||
hir::ExprUnary(_, ref e) |
|
||||
hir::ExprParen(ref e) => {
|
||||
hir::ExprUnary(_, ref e) => {
|
||||
self.propagate_through_expr(&**e, succ)
|
||||
}
|
||||
|
||||
@ -1435,7 +1434,7 @@ fn check_expr(this: &mut Liveness, expr: &Expr) {
|
||||
hir::ExprCast(..) | hir::ExprUnary(..) | hir::ExprRet(..) |
|
||||
hir::ExprBreak(..) | hir::ExprAgain(..) | hir::ExprLit(_) |
|
||||
hir::ExprBlock(..) | hir::ExprAddrOf(..) |
|
||||
hir::ExprStruct(..) | hir::ExprRepeat(..) | hir::ExprParen(..) |
|
||||
hir::ExprStruct(..) | hir::ExprRepeat(..) |
|
||||
hir::ExprClosure(..) | hir::ExprPath(..) | hir::ExprBox(..) |
|
||||
hir::ExprRange(..) => {
|
||||
visit::walk_expr(this, expr);
|
||||
|
@ -519,10 +519,6 @@ impl<'t, 'a,'tcx> MemCategorizationContext<'t, 'a, 'tcx> {
|
||||
self.cat_def(expr.id, expr.span, expr_ty, def)
|
||||
}
|
||||
|
||||
hir::ExprParen(ref e) => {
|
||||
self.cat_expr(&**e)
|
||||
}
|
||||
|
||||
hir::ExprAddrOf(..) | hir::ExprCall(..) |
|
||||
hir::ExprAssign(..) | hir::ExprAssignOp(..) |
|
||||
hir::ExprClosure(..) | hir::ExprRet(..) |
|
||||
|
@ -997,8 +997,7 @@ fn resolve_local(visitor: &mut RegionResolutionVisitor, local: &hir::Local) {
|
||||
hir::ExprUnary(hir::UnUniq, ref subexpr) => {
|
||||
record_rvalue_scope_if_borrow_expr(visitor, &**subexpr, blk_id);
|
||||
}
|
||||
hir::ExprCast(ref subexpr, _) |
|
||||
hir::ExprParen(ref subexpr) => {
|
||||
hir::ExprCast(ref subexpr, _) => {
|
||||
record_rvalue_scope_if_borrow_expr(visitor, &**subexpr, blk_id)
|
||||
}
|
||||
hir::ExprBlock(ref block) => {
|
||||
@ -1047,8 +1046,7 @@ fn resolve_local(visitor: &mut RegionResolutionVisitor, local: &hir::Local) {
|
||||
hir::ExprUnary(hir::UnDeref, ref subexpr) |
|
||||
hir::ExprField(ref subexpr, _) |
|
||||
hir::ExprTupField(ref subexpr, _) |
|
||||
hir::ExprIndex(ref subexpr, _) |
|
||||
hir::ExprParen(ref subexpr) => {
|
||||
hir::ExprIndex(ref subexpr, _) => {
|
||||
expr = &**subexpr;
|
||||
}
|
||||
_ => {
|
||||
|
@ -249,7 +249,6 @@ mod svh_visitor {
|
||||
SawExprInlineAsm(&'a hir::InlineAsm),
|
||||
SawExprStruct,
|
||||
SawExprRepeat,
|
||||
SawExprParen,
|
||||
}
|
||||
|
||||
fn saw_expr<'a>(node: &'a Expr_) -> SawExprComponent<'a> {
|
||||
@ -283,7 +282,6 @@ mod svh_visitor {
|
||||
ExprInlineAsm(ref asm) => SawExprInlineAsm(asm),
|
||||
ExprStruct(..) => SawExprStruct,
|
||||
ExprRepeat(..) => SawExprRepeat,
|
||||
ExprParen(..) => SawExprParen,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1164,7 +1164,6 @@ pub fn noop_fold_expr<T: Folder>(Expr {id, node, span}: Expr, folder: &mut T) ->
|
||||
fields.move_map(|x| folder.fold_field(x)),
|
||||
maybe_expr.map(|x| folder.fold_expr(x)))
|
||||
},
|
||||
ExprParen(ex) => ExprParen(folder.fold_expr(ex))
|
||||
},
|
||||
span: folder.new_span(span)
|
||||
}
|
||||
|
@ -703,9 +703,6 @@ pub enum Expr_ {
|
||||
/// For example, `[1u8; 5]`. The first expression is the element
|
||||
/// to be repeated; the second is the number of times to repeat it.
|
||||
ExprRepeat(P<Expr>, P<Expr>),
|
||||
|
||||
/// No-op: used solely so we can pretty-print faithfully
|
||||
ExprParen(P<Expr>)
|
||||
}
|
||||
|
||||
/// The explicit Self type in a "qualified path". The actual
|
||||
|
@ -810,7 +810,9 @@ pub fn lower_expr(e: &Expr) -> P<hir::Expr> {
|
||||
fields.iter().map(|x| lower_field(x)).collect(),
|
||||
maybe_expr.as_ref().map(|x| lower_expr(x)))
|
||||
},
|
||||
ExprParen(ref ex) => hir::ExprParen(lower_expr(ex)),
|
||||
ExprParen(ref ex) => {
|
||||
return lower_expr(ex);
|
||||
}
|
||||
ExprIfLet(..) |
|
||||
ExprWhileLet(..) |
|
||||
ExprForLoop(..) |
|
||||
|
@ -1556,11 +1556,6 @@ impl<'a> State<'a> {
|
||||
|
||||
try!(self.pclose());
|
||||
}
|
||||
hir::ExprParen(ref e) => {
|
||||
try!(self.popen());
|
||||
try!(self.print_expr(&**e));
|
||||
try!(self.pclose());
|
||||
}
|
||||
}
|
||||
try!(self.ann.post(self, NodeExpr(expr)));
|
||||
self.end()
|
||||
|
@ -814,9 +814,6 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr) {
|
||||
ExprRet(ref optional_expression) => {
|
||||
walk_expr_opt(visitor, optional_expression)
|
||||
}
|
||||
ExprParen(ref subexpression) => {
|
||||
visitor.visit_expr(&**subexpression)
|
||||
}
|
||||
ExprInlineAsm(ref ia) => {
|
||||
for input in &ia.inputs {
|
||||
let (_, ref input) = *input;
|
||||
|
@ -154,9 +154,6 @@ impl LintPass for TypeLimits {
|
||||
self.negated_expr_id = expr.id;
|
||||
}
|
||||
},
|
||||
hir::ExprParen(ref expr) if self.negated_expr_id == e.id => {
|
||||
self.negated_expr_id = expr.id;
|
||||
},
|
||||
hir::ExprBinary(binop, ref l, ref r) => {
|
||||
if is_comparison(binop) && !check_limits(cx.tcx, binop, &**l, &**r) {
|
||||
cx.span_lint(UNUSED_COMPARISONS, e.span,
|
||||
|
@ -33,9 +33,6 @@ impl<H:Hair> Builder<H> {
|
||||
ExprKind::Scope { extent: _, value } => {
|
||||
return this.as_constant(value);
|
||||
}
|
||||
ExprKind::Paren { arg } => {
|
||||
return this.as_constant(arg);
|
||||
}
|
||||
ExprKind::Literal { literal } => {
|
||||
ConstantKind::Literal(literal)
|
||||
}
|
||||
|
@ -43,9 +43,6 @@ impl<H:Hair> Builder<H> {
|
||||
this.as_lvalue(block, value)
|
||||
})
|
||||
}
|
||||
ExprKind::Paren { arg } => {
|
||||
this.as_lvalue(block, arg)
|
||||
}
|
||||
ExprKind::Field { lhs, name } => {
|
||||
let lvalue = unpack!(block = this.as_lvalue(block, lhs));
|
||||
let lvalue = lvalue.field(name);
|
||||
|
@ -39,16 +39,10 @@ impl<H:Hair> Builder<H> {
|
||||
block, expr);
|
||||
let this = self;
|
||||
|
||||
match expr.kind {
|
||||
ExprKind::Scope { extent, value } => {
|
||||
return this.in_scope(extent, block, |this| {
|
||||
this.as_operand(block, value)
|
||||
});
|
||||
}
|
||||
ExprKind::Paren { arg } => {
|
||||
return this.as_operand(block, arg);
|
||||
}
|
||||
_ => { }
|
||||
if let ExprKind::Scope { extent, value } = expr.kind {
|
||||
return this.in_scope(extent, block, |this| {
|
||||
this.as_operand(block, value)
|
||||
});
|
||||
}
|
||||
|
||||
let category = Category::of(&expr.kind).unwrap();
|
||||
|
@ -46,9 +46,6 @@ impl<H:Hair> Builder<H> {
|
||||
this.as_rvalue(block, value)
|
||||
})
|
||||
}
|
||||
ExprKind::Paren { arg } => {
|
||||
this.as_rvalue(block, arg)
|
||||
}
|
||||
ExprKind::InlineAsm { asm } => {
|
||||
block.and(Rvalue::InlineAsm(asm))
|
||||
}
|
||||
|
@ -37,16 +37,10 @@ impl<H:Hair> Builder<H> {
|
||||
block, expr);
|
||||
let this = self;
|
||||
|
||||
match expr.kind {
|
||||
ExprKind::Scope { extent, value } => {
|
||||
return this.in_scope(extent, block, |this| {
|
||||
this.as_temp(block, value)
|
||||
});
|
||||
}
|
||||
ExprKind::Paren { arg } => {
|
||||
return this.as_temp(block, arg);
|
||||
}
|
||||
_ => { }
|
||||
if let ExprKind::Scope { extent, value } = expr.kind {
|
||||
return this.in_scope(extent, block, |this| {
|
||||
this.as_temp(block, value)
|
||||
});
|
||||
}
|
||||
|
||||
let expr_ty = expr.ty.clone();
|
||||
|
@ -43,9 +43,7 @@ pub enum RvalueFunc {
|
||||
impl Category {
|
||||
pub fn of<H:Hair>(ek: &ExprKind<H>) -> Option<Category> {
|
||||
match *ek {
|
||||
ExprKind::Scope { .. } |
|
||||
ExprKind::Paren { .. } =>
|
||||
None,
|
||||
ExprKind::Scope { .. } => None,
|
||||
|
||||
ExprKind::Field { .. } |
|
||||
ExprKind::Deref { .. } |
|
||||
|
@ -40,9 +40,6 @@ impl<H:Hair> Builder<H> {
|
||||
this.into(destination, block, value)
|
||||
})
|
||||
}
|
||||
ExprKind::Paren { arg } => {
|
||||
this.into(destination, block, arg)
|
||||
}
|
||||
ExprKind::Block { body: ast_block } => {
|
||||
this.ast_block(destination, block, ast_block)
|
||||
}
|
||||
|
@ -171,7 +171,6 @@ pub struct Expr<H:Hair> {
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum ExprKind<H:Hair> {
|
||||
Scope { extent: H::CodeExtent, value: ExprRef<H> },
|
||||
Paren { arg: ExprRef<H> }, // ugh. should be able to remove this!
|
||||
Box { place: Option<ExprRef<H>>, value: ExprRef<H> },
|
||||
Call { fun: ExprRef<H>, args: Vec<ExprRef<H>> },
|
||||
Deref { arg: ExprRef<H> }, // NOT overloaded!
|
||||
|
@ -267,8 +267,6 @@ impl<'a,'tcx:'a> Mirror<Cx<'a,'tcx>> for &'tcx hir::Expr {
|
||||
|
||||
// Now comes the rote stuff:
|
||||
|
||||
hir::ExprParen(ref p) =>
|
||||
ExprKind::Paren { arg: p.to_ref() },
|
||||
hir::ExprRepeat(ref v, ref c) =>
|
||||
ExprKind::Repeat { value: v.to_ref(), count: c.to_ref() },
|
||||
hir::ExprRet(ref v) =>
|
||||
|
@ -703,7 +703,6 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
let mut cur = sub;
|
||||
loop {
|
||||
match cur.node {
|
||||
hir::ExprParen(ref sub) => cur = sub,
|
||||
hir::ExprBlock(ref blk) => {
|
||||
if let Some(ref sub) = blk.expr {
|
||||
cur = sub;
|
||||
@ -830,7 +829,6 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
let mut callee = &**callee;
|
||||
loop {
|
||||
callee = match callee.node {
|
||||
hir::ExprParen(ref inner) => &**inner,
|
||||
hir::ExprBlock(ref block) => match block.expr {
|
||||
Some(ref tail) => &**tail,
|
||||
None => break,
|
||||
@ -870,7 +868,6 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
const_fn_call(cx, MethodCallKey(method_call),
|
||||
method_did, &arg_vals, param_substs)
|
||||
},
|
||||
hir::ExprParen(ref e) => const_expr(cx, &**e, param_substs, fn_args).0,
|
||||
hir::ExprBlock(ref block) => {
|
||||
match block.expr {
|
||||
Some(ref expr) => const_expr(cx, &**expr, param_substs, fn_args).0,
|
||||
|
@ -322,8 +322,7 @@ fn walk_expr(cx: &CrateContext,
|
||||
hir::ExprCast(ref sub_exp, _) |
|
||||
hir::ExprAddrOf(_, ref sub_exp) |
|
||||
hir::ExprField(ref sub_exp, _) |
|
||||
hir::ExprTupField(ref sub_exp, _) |
|
||||
hir::ExprParen(ref sub_exp) =>
|
||||
hir::ExprTupField(ref sub_exp, _) =>
|
||||
walk_expr(cx, &**sub_exp, scope_stack, scope_map),
|
||||
|
||||
hir::ExprBox(ref place, ref sub_expr) => {
|
||||
|
@ -630,9 +630,6 @@ fn trans_datum_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
let _icx = push_ctxt("trans_datum_unadjusted");
|
||||
|
||||
match expr.node {
|
||||
hir::ExprParen(ref e) => {
|
||||
trans(bcx, &**e)
|
||||
}
|
||||
hir::ExprPath(..) => {
|
||||
trans_def(bcx, expr, bcx.def(expr.id))
|
||||
}
|
||||
@ -934,9 +931,6 @@ fn trans_rvalue_stmt_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
debuginfo::set_source_location(bcx.fcx, expr.id, expr.span);
|
||||
|
||||
match expr.node {
|
||||
hir::ExprParen(ref e) => {
|
||||
trans_into(bcx, &**e, Ignore)
|
||||
}
|
||||
hir::ExprBreak(label_opt) => {
|
||||
controlflow::trans_break(bcx, expr, label_opt.map(|l| l.node))
|
||||
}
|
||||
@ -1050,9 +1044,6 @@ fn trans_rvalue_dps_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
debuginfo::set_source_location(bcx.fcx, expr.id, expr.span);
|
||||
|
||||
match expr.node {
|
||||
hir::ExprParen(ref e) => {
|
||||
trans_into(bcx, &**e, dest)
|
||||
}
|
||||
hir::ExprPath(..) => {
|
||||
trans_def_dps_unadjusted(bcx, expr, bcx.def(expr.id), dest)
|
||||
}
|
||||
@ -2750,7 +2741,5 @@ fn expr_kind(tcx: &ty::ctxt, expr: &hir::Expr) -> ExprKind {
|
||||
ExprKind::RvalueDps
|
||||
}
|
||||
}
|
||||
|
||||
hir::ExprParen(ref e) => expr_kind(tcx, &**e),
|
||||
}
|
||||
}
|
||||
|
@ -468,7 +468,6 @@ impl<'a,'tcx> ConfirmContext<'a,'tcx> {
|
||||
loop {
|
||||
let last = exprs[exprs.len() - 1];
|
||||
match last.node {
|
||||
hir::ExprParen(ref expr) |
|
||||
hir::ExprField(ref expr, _) |
|
||||
hir::ExprTupField(ref expr, _) |
|
||||
hir::ExprIndex(ref expr, _) |
|
||||
|
@ -3444,13 +3444,6 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
|
||||
}
|
||||
fcx.write_ty(id, fcx.infcx().next_diverging_ty_var());
|
||||
}
|
||||
hir::ExprParen(ref a) => {
|
||||
check_expr_with_expectation_and_lvalue_pref(fcx,
|
||||
&**a,
|
||||
expected,
|
||||
lvalue_pref);
|
||||
fcx.write_ty(id, fcx.expr_ty(&**a));
|
||||
}
|
||||
hir::ExprAssign(ref lhs, ref rhs) => {
|
||||
check_expr_with_lvalue_pref(fcx, &**lhs, PreferMutLvalue);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user