Skip to content

Commit d21bfff

Browse files
committed
Remove hir::ExprParen
1 parent 70c6fb9 commit d21bfff

File tree

28 files changed

+18
-103
lines changed

28 files changed

+18
-103
lines changed

src/librustc/middle/cfg/construct.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,6 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
354354
hir::ExprAddrOf(_, ref e) |
355355
hir::ExprCast(ref e, _) |
356356
hir::ExprUnary(_, ref e) |
357-
hir::ExprParen(ref e) |
358357
hir::ExprField(ref e, _) |
359358
hir::ExprTupField(ref e, _) => {
360359
self.straightline(expr, pred, Some(&**e).into_iter())

src/librustc/middle/check_const.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,6 @@ fn check_expr<'a, 'tcx>(v: &mut CheckCrateVisitor<'a, 'tcx>,
678678
let mut callee = &**callee;
679679
loop {
680680
callee = match callee.node {
681-
hir::ExprParen(ref inner) => &**inner,
682681
hir::ExprBlock(ref block) => match block.expr {
683682
Some(ref tail) => &**tail,
684683
None => break
@@ -763,7 +762,6 @@ fn check_expr<'a, 'tcx>(v: &mut CheckCrateVisitor<'a, 'tcx>,
763762
hir::ExprField(..) |
764763
hir::ExprTupField(..) |
765764
hir::ExprVec(_) |
766-
hir::ExprParen(..) |
767765
hir::ExprTup(..) => {}
768766

769767
// Conditional control flow (possible to implement).

src/librustc/middle/const_eval.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -996,7 +996,6 @@ pub fn eval_const_expr_partial<'tcx>(tcx: &ty::ctxt<'tcx>,
996996
hir::ExprLit(ref lit) => {
997997
lit_to_const(&**lit, ety)
998998
}
999-
hir::ExprParen(ref e) => try!(eval_const_expr_partial(tcx, &**e, ty_hint)),
1000999
hir::ExprBlock(ref block) => {
10011000
match block.expr {
10021001
Some(ref expr) => try!(eval_const_expr_partial(tcx, &**expr, ty_hint)),

src/librustc/middle/expr_use_visitor.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -362,9 +362,6 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> {
362362
let cmt = return_if_err!(self.mc.cat_expr(expr));
363363
self.delegate.borrow(expr.id, expr.span, cmt, r, bk, cause);
364364

365-
// Note: Unlike consume, we can ignore ExprParen. cat_expr
366-
// already skips over them, and walk will uncover any
367-
// attachments or whatever.
368365
self.walk_expr(expr)
369366
}
370367

@@ -378,10 +375,6 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> {
378375
self.walk_adjustment(expr);
379376

380377
match expr.node {
381-
hir::ExprParen(ref subexpr) => {
382-
self.walk_expr(&**subexpr)
383-
}
384-
385378
hir::ExprPath(..) => { }
386379

387380
hir::ExprUnary(hir::UnDeref, ref base) => { // *base

src/librustc/middle/liveness.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ fn visit_expr(ir: &mut IrMaps, expr: &Expr) {
495495
hir::ExprAgain(_) | hir::ExprLit(_) | hir::ExprRet(..) |
496496
hir::ExprBlock(..) | hir::ExprAssign(..) | hir::ExprAssignOp(..) |
497497
hir::ExprStruct(..) | hir::ExprRepeat(..) |
498-
hir::ExprParen(..) | hir::ExprInlineAsm(..) | hir::ExprBox(..) |
498+
hir::ExprInlineAsm(..) | hir::ExprBox(..) |
499499
hir::ExprRange(..) => {
500500
visit::walk_expr(ir, expr);
501501
}
@@ -1161,8 +1161,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
11611161
hir::ExprBox(None, ref e) |
11621162
hir::ExprAddrOf(_, ref e) |
11631163
hir::ExprCast(ref e, _) |
1164-
hir::ExprUnary(_, ref e) |
1165-
hir::ExprParen(ref e) => {
1164+
hir::ExprUnary(_, ref e) => {
11661165
self.propagate_through_expr(&**e, succ)
11671166
}
11681167

@@ -1435,7 +1434,7 @@ fn check_expr(this: &mut Liveness, expr: &Expr) {
14351434
hir::ExprCast(..) | hir::ExprUnary(..) | hir::ExprRet(..) |
14361435
hir::ExprBreak(..) | hir::ExprAgain(..) | hir::ExprLit(_) |
14371436
hir::ExprBlock(..) | hir::ExprAddrOf(..) |
1438-
hir::ExprStruct(..) | hir::ExprRepeat(..) | hir::ExprParen(..) |
1437+
hir::ExprStruct(..) | hir::ExprRepeat(..) |
14391438
hir::ExprClosure(..) | hir::ExprPath(..) | hir::ExprBox(..) |
14401439
hir::ExprRange(..) => {
14411440
visit::walk_expr(this, expr);

src/librustc/middle/mem_categorization.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -519,10 +519,6 @@ impl<'t, 'a,'tcx> MemCategorizationContext<'t, 'a, 'tcx> {
519519
self.cat_def(expr.id, expr.span, expr_ty, def)
520520
}
521521

522-
hir::ExprParen(ref e) => {
523-
self.cat_expr(&**e)
524-
}
525-
526522
hir::ExprAddrOf(..) | hir::ExprCall(..) |
527523
hir::ExprAssign(..) | hir::ExprAssignOp(..) |
528524
hir::ExprClosure(..) | hir::ExprRet(..) |

src/librustc/middle/region.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -997,8 +997,7 @@ fn resolve_local(visitor: &mut RegionResolutionVisitor, local: &hir::Local) {
997997
hir::ExprUnary(hir::UnUniq, ref subexpr) => {
998998
record_rvalue_scope_if_borrow_expr(visitor, &**subexpr, blk_id);
999999
}
1000-
hir::ExprCast(ref subexpr, _) |
1001-
hir::ExprParen(ref subexpr) => {
1000+
hir::ExprCast(ref subexpr, _) => {
10021001
record_rvalue_scope_if_borrow_expr(visitor, &**subexpr, blk_id)
10031002
}
10041003
hir::ExprBlock(ref block) => {
@@ -1047,8 +1046,7 @@ fn resolve_local(visitor: &mut RegionResolutionVisitor, local: &hir::Local) {
10471046
hir::ExprUnary(hir::UnDeref, ref subexpr) |
10481047
hir::ExprField(ref subexpr, _) |
10491048
hir::ExprTupField(ref subexpr, _) |
1050-
hir::ExprIndex(ref subexpr, _) |
1051-
hir::ExprParen(ref subexpr) => {
1049+
hir::ExprIndex(ref subexpr, _) => {
10521050
expr = &**subexpr;
10531051
}
10541052
_ => {

src/librustc_back/svh.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,6 @@ mod svh_visitor {
249249
SawExprInlineAsm(&'a hir::InlineAsm),
250250
SawExprStruct,
251251
SawExprRepeat,
252-
SawExprParen,
253252
}
254253

255254
fn saw_expr<'a>(node: &'a Expr_) -> SawExprComponent<'a> {
@@ -283,7 +282,6 @@ mod svh_visitor {
283282
ExprInlineAsm(ref asm) => SawExprInlineAsm(asm),
284283
ExprStruct(..) => SawExprStruct,
285284
ExprRepeat(..) => SawExprRepeat,
286-
ExprParen(..) => SawExprParen,
287285
}
288286
}
289287

src/librustc_front/fold.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1164,7 +1164,6 @@ pub fn noop_fold_expr<T: Folder>(Expr {id, node, span}: Expr, folder: &mut T) ->
11641164
fields.move_map(|x| folder.fold_field(x)),
11651165
maybe_expr.map(|x| folder.fold_expr(x)))
11661166
},
1167-
ExprParen(ex) => ExprParen(folder.fold_expr(ex))
11681167
},
11691168
span: folder.new_span(span)
11701169
}

src/librustc_front/hir.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -703,9 +703,6 @@ pub enum Expr_ {
703703
/// For example, `[1u8; 5]`. The first expression is the element
704704
/// to be repeated; the second is the number of times to repeat it.
705705
ExprRepeat(P<Expr>, P<Expr>),
706-
707-
/// No-op: used solely so we can pretty-print faithfully
708-
ExprParen(P<Expr>)
709706
}
710707

711708
/// The explicit Self type in a "qualified path". The actual

src/librustc_front/lowering.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -810,7 +810,9 @@ pub fn lower_expr(e: &Expr) -> P<hir::Expr> {
810810
fields.iter().map(|x| lower_field(x)).collect(),
811811
maybe_expr.as_ref().map(|x| lower_expr(x)))
812812
},
813-
ExprParen(ref ex) => hir::ExprParen(lower_expr(ex)),
813+
ExprParen(ref ex) => {
814+
return lower_expr(ex);
815+
}
814816
ExprIfLet(..) |
815817
ExprWhileLet(..) |
816818
ExprForLoop(..) |

src/librustc_front/print/pprust.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1556,11 +1556,6 @@ impl<'a> State<'a> {
15561556

15571557
try!(self.pclose());
15581558
}
1559-
hir::ExprParen(ref e) => {
1560-
try!(self.popen());
1561-
try!(self.print_expr(&**e));
1562-
try!(self.pclose());
1563-
}
15641559
}
15651560
try!(self.ann.post(self, NodeExpr(expr)));
15661561
self.end()

src/librustc_front/visit.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -814,9 +814,6 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr) {
814814
ExprRet(ref optional_expression) => {
815815
walk_expr_opt(visitor, optional_expression)
816816
}
817-
ExprParen(ref subexpression) => {
818-
visitor.visit_expr(&**subexpression)
819-
}
820817
ExprInlineAsm(ref ia) => {
821818
for input in &ia.inputs {
822819
let (_, ref input) = *input;

src/librustc_lint/builtin.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,6 @@ impl LintPass for TypeLimits {
154154
self.negated_expr_id = expr.id;
155155
}
156156
},
157-
hir::ExprParen(ref expr) if self.negated_expr_id == e.id => {
158-
self.negated_expr_id = expr.id;
159-
},
160157
hir::ExprBinary(binop, ref l, ref r) => {
161158
if is_comparison(binop) && !check_limits(cx.tcx, binop, &**l, &**r) {
162159
cx.span_lint(UNUSED_COMPARISONS, e.span,

src/librustc_mir/build/expr/as_constant.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@ impl<H:Hair> Builder<H> {
3333
ExprKind::Scope { extent: _, value } => {
3434
return this.as_constant(value);
3535
}
36-
ExprKind::Paren { arg } => {
37-
return this.as_constant(arg);
38-
}
3936
ExprKind::Literal { literal } => {
4037
ConstantKind::Literal(literal)
4138
}

src/librustc_mir/build/expr/as_lvalue.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,6 @@ impl<H:Hair> Builder<H> {
4343
this.as_lvalue(block, value)
4444
})
4545
}
46-
ExprKind::Paren { arg } => {
47-
this.as_lvalue(block, arg)
48-
}
4946
ExprKind::Field { lhs, name } => {
5047
let lvalue = unpack!(block = this.as_lvalue(block, lhs));
5148
let lvalue = lvalue.field(name);

src/librustc_mir/build/expr/as_operand.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,10 @@ impl<H:Hair> Builder<H> {
3939
block, expr);
4040
let this = self;
4141

42-
match expr.kind {
43-
ExprKind::Scope { extent, value } => {
44-
return this.in_scope(extent, block, |this| {
45-
this.as_operand(block, value)
46-
});
47-
}
48-
ExprKind::Paren { arg } => {
49-
return this.as_operand(block, arg);
50-
}
51-
_ => { }
42+
if let ExprKind::Scope { extent, value } = expr.kind {
43+
return this.in_scope(extent, block, |this| {
44+
this.as_operand(block, value)
45+
});
5246
}
5347

5448
let category = Category::of(&expr.kind).unwrap();

src/librustc_mir/build/expr/as_rvalue.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,6 @@ impl<H:Hair> Builder<H> {
4646
this.as_rvalue(block, value)
4747
})
4848
}
49-
ExprKind::Paren { arg } => {
50-
this.as_rvalue(block, arg)
51-
}
5249
ExprKind::InlineAsm { asm } => {
5350
block.and(Rvalue::InlineAsm(asm))
5451
}

src/librustc_mir/build/expr/as_temp.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,10 @@ impl<H:Hair> Builder<H> {
3737
block, expr);
3838
let this = self;
3939

40-
match expr.kind {
41-
ExprKind::Scope { extent, value } => {
42-
return this.in_scope(extent, block, |this| {
43-
this.as_temp(block, value)
44-
});
45-
}
46-
ExprKind::Paren { arg } => {
47-
return this.as_temp(block, arg);
48-
}
49-
_ => { }
40+
if let ExprKind::Scope { extent, value } = expr.kind {
41+
return this.in_scope(extent, block, |this| {
42+
this.as_temp(block, value)
43+
});
5044
}
5145

5246
let expr_ty = expr.ty.clone();

src/librustc_mir/build/expr/category.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,7 @@ pub enum RvalueFunc {
4343
impl Category {
4444
pub fn of<H:Hair>(ek: &ExprKind<H>) -> Option<Category> {
4545
match *ek {
46-
ExprKind::Scope { .. } |
47-
ExprKind::Paren { .. } =>
48-
None,
46+
ExprKind::Scope { .. } => None,
4947

5048
ExprKind::Field { .. } |
5149
ExprKind::Deref { .. } |

src/librustc_mir/build/expr/into.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,6 @@ impl<H:Hair> Builder<H> {
4040
this.into(destination, block, value)
4141
})
4242
}
43-
ExprKind::Paren { arg } => {
44-
this.into(destination, block, arg)
45-
}
4643
ExprKind::Block { body: ast_block } => {
4744
this.ast_block(destination, block, ast_block)
4845
}

src/librustc_mir/hair.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,6 @@ pub struct Expr<H:Hair> {
171171
#[derive(Clone, Debug)]
172172
pub enum ExprKind<H:Hair> {
173173
Scope { extent: H::CodeExtent, value: ExprRef<H> },
174-
Paren { arg: ExprRef<H> }, // ugh. should be able to remove this!
175174
Box { place: Option<ExprRef<H>>, value: ExprRef<H> },
176175
Call { fun: ExprRef<H>, args: Vec<ExprRef<H>> },
177176
Deref { arg: ExprRef<H> }, // NOT overloaded!

src/librustc_mir/tcx/expr.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,8 +267,6 @@ impl<'a,'tcx:'a> Mirror<Cx<'a,'tcx>> for &'tcx hir::Expr {
267267

268268
// Now comes the rote stuff:
269269

270-
hir::ExprParen(ref p) =>
271-
ExprKind::Paren { arg: p.to_ref() },
272270
hir::ExprRepeat(ref v, ref c) =>
273271
ExprKind::Repeat { value: v.to_ref(), count: c.to_ref() },
274272
hir::ExprRet(ref v) =>

src/librustc_trans/trans/consts.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,6 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
703703
let mut cur = sub;
704704
loop {
705705
match cur.node {
706-
hir::ExprParen(ref sub) => cur = sub,
707706
hir::ExprBlock(ref blk) => {
708707
if let Some(ref sub) = blk.expr {
709708
cur = sub;
@@ -830,7 +829,6 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
830829
let mut callee = &**callee;
831830
loop {
832831
callee = match callee.node {
833-
hir::ExprParen(ref inner) => &**inner,
834832
hir::ExprBlock(ref block) => match block.expr {
835833
Some(ref tail) => &**tail,
836834
None => break,
@@ -870,7 +868,6 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
870868
const_fn_call(cx, MethodCallKey(method_call),
871869
method_did, &arg_vals, param_substs)
872870
},
873-
hir::ExprParen(ref e) => const_expr(cx, &**e, param_substs, fn_args).0,
874871
hir::ExprBlock(ref block) => {
875872
match block.expr {
876873
Some(ref expr) => const_expr(cx, &**expr, param_substs, fn_args).0,

src/librustc_trans/trans/debuginfo/create_scope_map.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,8 +322,7 @@ fn walk_expr(cx: &CrateContext,
322322
hir::ExprCast(ref sub_exp, _) |
323323
hir::ExprAddrOf(_, ref sub_exp) |
324324
hir::ExprField(ref sub_exp, _) |
325-
hir::ExprTupField(ref sub_exp, _) |
326-
hir::ExprParen(ref sub_exp) =>
325+
hir::ExprTupField(ref sub_exp, _) =>
327326
walk_expr(cx, &**sub_exp, scope_stack, scope_map),
328327

329328
hir::ExprBox(ref place, ref sub_expr) => {

src/librustc_trans/trans/expr.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -630,9 +630,6 @@ fn trans_datum_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
630630
let _icx = push_ctxt("trans_datum_unadjusted");
631631

632632
match expr.node {
633-
hir::ExprParen(ref e) => {
634-
trans(bcx, &**e)
635-
}
636633
hir::ExprPath(..) => {
637634
trans_def(bcx, expr, bcx.def(expr.id))
638635
}
@@ -934,9 +931,6 @@ fn trans_rvalue_stmt_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
934931
debuginfo::set_source_location(bcx.fcx, expr.id, expr.span);
935932

936933
match expr.node {
937-
hir::ExprParen(ref e) => {
938-
trans_into(bcx, &**e, Ignore)
939-
}
940934
hir::ExprBreak(label_opt) => {
941935
controlflow::trans_break(bcx, expr, label_opt.map(|l| l.node))
942936
}
@@ -1050,9 +1044,6 @@ fn trans_rvalue_dps_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
10501044
debuginfo::set_source_location(bcx.fcx, expr.id, expr.span);
10511045

10521046
match expr.node {
1053-
hir::ExprParen(ref e) => {
1054-
trans_into(bcx, &**e, dest)
1055-
}
10561047
hir::ExprPath(..) => {
10571048
trans_def_dps_unadjusted(bcx, expr, bcx.def(expr.id), dest)
10581049
}
@@ -2750,7 +2741,5 @@ fn expr_kind(tcx: &ty::ctxt, expr: &hir::Expr) -> ExprKind {
27502741
ExprKind::RvalueDps
27512742
}
27522743
}
2753-
2754-
hir::ExprParen(ref e) => expr_kind(tcx, &**e),
27552744
}
27562745
}

src/librustc_typeck/check/method/confirm.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,6 @@ impl<'a,'tcx> ConfirmContext<'a,'tcx> {
468468
loop {
469469
let last = exprs[exprs.len() - 1];
470470
match last.node {
471-
hir::ExprParen(ref expr) |
472471
hir::ExprField(ref expr, _) |
473472
hir::ExprTupField(ref expr, _) |
474473
hir::ExprIndex(ref expr, _) |

src/librustc_typeck/check/mod.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3444,13 +3444,6 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
34443444
}
34453445
fcx.write_ty(id, fcx.infcx().next_diverging_ty_var());
34463446
}
3447-
hir::ExprParen(ref a) => {
3448-
check_expr_with_expectation_and_lvalue_pref(fcx,
3449-
&**a,
3450-
expected,
3451-
lvalue_pref);
3452-
fcx.write_ty(id, fcx.expr_ty(&**a));
3453-
}
34543447
hir::ExprAssign(ref lhs, ref rhs) => {
34553448
check_expr_with_lvalue_pref(fcx, &**lhs, PreferMutLvalue);
34563449

0 commit comments

Comments
 (0)