Skip to content

Commit d792183

Browse files
committed
fallout from removing hir::ExprRange
A whole bunch of stuff gets folded into struct handling! Plus, removes an ugly hack from trans and accidentally fixes a bug with constructing ranges from references (see later commits with tests).
1 parent a331278 commit d792183

File tree

14 files changed

+3
-217
lines changed

14 files changed

+3
-217
lines changed

src/librustc/middle/cfg/construct.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -317,12 +317,6 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
317317
self.call(expr, pred, &l, Some(&**r).into_iter())
318318
}
319319

320-
hir::ExprRange(ref start, ref end) => {
321-
let fields = start.as_ref().map(|e| &**e).into_iter()
322-
.chain(end.as_ref().map(|e| &**e));
323-
self.straightline(expr, pred, fields)
324-
}
325-
326320
hir::ExprUnary(_, ref e) if self.tcx.is_method_call(expr.id) => {
327321
self.call(expr, pred, &e, None::<hir::Expr>.iter())
328322
}

src/librustc/middle/expr_use_visitor.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -399,11 +399,6 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> {
399399
}
400400
}
401401

402-
hir::ExprRange(ref start, ref end) => {
403-
start.as_ref().map(|e| self.consume_expr(&e));
404-
end.as_ref().map(|e| self.consume_expr(&e));
405-
}
406-
407402
hir::ExprCall(ref callee, ref args) => { // callee(args)
408403
self.walk_callee(expr, &callee);
409404
self.consume_exprs(args);

src/librustc/middle/liveness.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ fn visit_expr(ir: &mut IrMaps, expr: &Expr) {
498498
hir::ExprBlock(..) | hir::ExprAssign(..) | hir::ExprAssignOp(..) |
499499
hir::ExprStruct(..) | hir::ExprRepeat(..) |
500500
hir::ExprInlineAsm(..) | hir::ExprBox(..) |
501-
hir::ExprRange(..) | hir::ExprType(..) => {
501+
hir::ExprType(..) => {
502502
intravisit::walk_expr(ir, expr);
503503
}
504504
}
@@ -1154,11 +1154,6 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
11541154
self.propagate_through_expr(&l, r_succ)
11551155
}
11561156

1157-
hir::ExprRange(ref e1, ref e2) => {
1158-
let succ = e2.as_ref().map_or(succ, |e| self.propagate_through_expr(&e, succ));
1159-
e1.as_ref().map_or(succ, |e| self.propagate_through_expr(&e, succ))
1160-
}
1161-
11621157
hir::ExprBox(ref e) |
11631158
hir::ExprAddrOf(_, ref e) |
11641159
hir::ExprCast(ref e, _) |
@@ -1446,7 +1441,7 @@ fn check_expr(this: &mut Liveness, expr: &Expr) {
14461441
hir::ExprBlock(..) | hir::ExprAddrOf(..) |
14471442
hir::ExprStruct(..) | hir::ExprRepeat(..) |
14481443
hir::ExprClosure(..) | hir::ExprPath(..) | hir::ExprBox(..) |
1449-
hir::ExprRange(..) | hir::ExprType(..) => {
1444+
hir::ExprType(..) => {
14501445
intravisit::walk_expr(this, expr);
14511446
}
14521447
}

src/librustc/middle/mem_categorization.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ impl<'t, 'a,'tcx> MemCategorizationContext<'t, 'a, 'tcx> {
526526
hir::ExprAddrOf(..) | hir::ExprCall(..) |
527527
hir::ExprAssign(..) | hir::ExprAssignOp(..) |
528528
hir::ExprClosure(..) | hir::ExprRet(..) |
529-
hir::ExprUnary(..) | hir::ExprRange(..) |
529+
hir::ExprUnary(..) |
530530
hir::ExprMethodCall(..) | hir::ExprCast(..) |
531531
hir::ExprVec(..) | hir::ExprTup(..) | hir::ExprIf(..) |
532532
hir::ExprBinary(..) | hir::ExprWhile(..) |

src/librustc/middle/ty/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2002,7 +2002,6 @@ impl<'tcx> ctxt<'tcx> {
20022002
hir::ExprCall(..) |
20032003
hir::ExprMethodCall(..) |
20042004
hir::ExprStruct(..) |
2005-
hir::ExprRange(..) |
20062005
hir::ExprTup(..) |
20072006
hir::ExprIf(..) |
20082007
hir::ExprMatch(..) |

src/librustc_back/svh.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,6 @@ mod svh_visitor {
243243
SawExprAssign,
244244
SawExprAssignOp(hir::BinOp_),
245245
SawExprIndex,
246-
SawExprRange,
247246
SawExprPath(Option<usize>),
248247
SawExprAddrOf(hir::Mutability),
249248
SawExprRet,
@@ -275,7 +274,6 @@ mod svh_visitor {
275274
ExprField(_, name) => SawExprField(name.node.as_str()),
276275
ExprTupField(_, id) => SawExprTupField(id.node),
277276
ExprIndex(..) => SawExprIndex,
278-
ExprRange(..) => SawExprRange,
279277
ExprPath(ref qself, _) => SawExprPath(qself.as_ref().map(|q| q.position)),
280278
ExprAddrOf(m, _) => SawExprAddrOf(m),
281279
ExprBreak(id) => SawExprBreak(id.map(|id| id.node.name.as_str())),

src/librustc_front/fold.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,10 +1092,6 @@ pub fn noop_fold_expr<T: Folder>(Expr { id, node, span, attrs }: Expr, folder: &
10921092
ExprIndex(el, er) => {
10931093
ExprIndex(folder.fold_expr(el), folder.fold_expr(er))
10941094
}
1095-
ExprRange(e1, e2) => {
1096-
ExprRange(e1.map(|x| folder.fold_expr(x)),
1097-
e2.map(|x| folder.fold_expr(x)))
1098-
}
10991095
ExprPath(qself, path) => {
11001096
let qself = qself.map(|QSelf { ty, position }| {
11011097
QSelf {

src/librustc_front/intravisit.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -784,10 +784,6 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr) {
784784
visitor.visit_expr(main_expression);
785785
visitor.visit_expr(index_expression)
786786
}
787-
ExprRange(ref start, ref end) => {
788-
walk_list!(visitor, visit_expr, start);
789-
walk_list!(visitor, visit_expr, end);
790-
}
791787
ExprPath(ref maybe_qself, ref path) => {
792788
if let Some(ref qself) = *maybe_qself {
793789
visitor.visit_ty(&qself.ty);

src/librustc_front/print/pprust.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1459,15 +1459,6 @@ impl<'a> State<'a> {
14591459
try!(self.print_expr(&index));
14601460
try!(word(&mut self.s, "]"));
14611461
}
1462-
hir::ExprRange(ref start, ref end) => {
1463-
if let &Some(ref e) = start {
1464-
try!(self.print_expr(&e));
1465-
}
1466-
try!(word(&mut self.s, ".."));
1467-
if let &Some(ref e) = end {
1468-
try!(self.print_expr(&e));
1469-
}
1470-
}
14711462
hir::ExprPath(None, ref path) => {
14721463
try!(self.print_path(path, true, 0))
14731464
}

src/librustc_mir/hair/cx/expr.rs

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ use rustc::middle::ty::{self, VariantDef, Ty};
2222
use rustc::mir::repr::*;
2323
use rustc_front::hir;
2424
use rustc_front::util as hir_util;
25-
use syntax::parse::token;
2625
use syntax::ptr::P;
2726

2827
impl<'tcx> Mirror<'tcx> for &'tcx hir::Expr {
@@ -324,38 +323,6 @@ impl<'tcx> Mirror<'tcx> for &'tcx hir::Expr {
324323
}
325324
}
326325

327-
hir::ExprRange(ref start, ref end) => {
328-
let range_ty = cx.tcx.expr_ty(self);
329-
let (adt_def, substs) = match range_ty.sty {
330-
ty::TyStruct(adt_def, substs) => (adt_def, substs),
331-
_ => {
332-
cx.tcx.sess.span_bug(self.span, "unexpanded ast");
333-
}
334-
};
335-
336-
let field_expr_ref = |s: &'tcx P<hir::Expr>, name: &str| {
337-
let name = token::intern(name);
338-
let index = adt_def.variants[0].index_of_field_named(name).unwrap();
339-
FieldExprRef { name: Field::new(index), expr: s.to_ref() }
340-
};
341-
342-
let start_field = start.as_ref()
343-
.into_iter()
344-
.map(|s| field_expr_ref(s, "start"));
345-
346-
let end_field = end.as_ref()
347-
.into_iter()
348-
.map(|e| field_expr_ref(e, "end"));
349-
350-
ExprKind::Adt {
351-
adt_def: adt_def,
352-
variant_index: 0,
353-
substs: substs,
354-
fields: start_field.chain(end_field).collect(),
355-
base: None,
356-
}
357-
}
358-
359326
hir::ExprPath(..) => {
360327
convert_path_expr(cx, self)
361328
}

0 commit comments

Comments
 (0)