Skip to content

Commit 8a357e1

Browse files
committed
Add syntax for ranges
1 parent 53c5fcb commit 8a357e1

File tree

13 files changed

+83
-8
lines changed

13 files changed

+83
-8
lines changed

src/librustc/middle/cfg/construct.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,10 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
439439
start.iter().chain(end.iter()).map(|x| &**x))
440440
}
441441

442+
ast::ExprRange(..) => {
443+
self.tcx.sess.span_bug(expr.span, "non-desugared range");
444+
}
445+
442446
ast::ExprUnary(_, ref e) if self.is_method_call(expr) => {
443447
self.call(expr, pred, &**e, None::<ast::Expr>.iter())
444448
}

src/librustc/middle/expr_use_visitor.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,10 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
465465
assert!(overloaded);
466466
}
467467

468+
ast::ExprRange(..) => {
469+
self.tcx().sess.span_bug(expr.span, "non-desugared range");
470+
}
471+
468472
ast::ExprCall(ref callee, ref args) => { // callee(args)
469473
self.walk_callee(expr, &**callee);
470474
self.consume_exprs(args);

src/librustc/middle/liveness.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,9 @@ fn visit_expr(ir: &mut IrMaps, expr: &Expr) {
486486
ast::ExprWhileLet(..) => {
487487
ir.tcx.sess.span_bug(expr.span, "non-desugared ExprWhileLet");
488488
}
489+
ast::ExprRange(..) => {
490+
ir.tcx.sess.span_bug(expr.span, "non-desugared range");
491+
}
489492
ast::ExprForLoop(ref pat, _, _, _) => {
490493
pat_util::pat_bindings(&ir.tcx.def_map, &**pat, |bm, p_id, sp, path1| {
491494
debug!("adding local variable {} from for loop with bm {}",
@@ -1197,6 +1200,10 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
11971200
self.propagate_through_expr(&**e1, succ)
11981201
}
11991202

1203+
ast::ExprRange(..) => {
1204+
self.ir.tcx.sess.span_bug(expr.span, "non-desugared range");
1205+
}
1206+
12001207
ast::ExprBox(None, ref e) |
12011208
ast::ExprAddrOf(_, ref e) |
12021209
ast::ExprCast(ref e, _) |
@@ -1498,6 +1505,9 @@ fn check_expr(this: &mut Liveness, expr: &Expr) {
14981505
ast::ExprWhileLet(..) => {
14991506
this.ir.tcx.sess.span_bug(expr.span, "non-desugared ExprWhileLet");
15001507
}
1508+
ast::ExprRange(..) => {
1509+
this.ir.tcx.sess.span_bug(expr.span, "non-desugared range");
1510+
}
15011511
}
15021512
}
15031513

src/librustc/middle/mem_categorization.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,9 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
559559
ast::ExprWhileLet(..) => {
560560
self.tcx().sess.span_bug(expr.span, "non-desugared ExprWhileLet");
561561
}
562+
ast::ExprRange(..) => {
563+
self.tcx().sess.span_bug(expr.span, "non-desugared range");
564+
}
562565
}
563566
}
564567

src/librustc/middle/ty.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4273,6 +4273,9 @@ pub fn expr_kind(tcx: &ctxt, expr: &ast::Expr) -> ExprKind {
42734273
ast::ExprWhileLet(..) => {
42744274
tcx.sess.span_bug(expr.span, "non-desugared ExprWhileLet");
42754275
}
4276+
ast::ExprRange(..) => {
4277+
tcx.sess.span_bug(expr.span, "non-desugared range");
4278+
}
42764279

42774280
ast::ExprLit(ref lit) if lit_is_str(&**lit) => {
42784281
RvalueDpsExpr

src/librustc_back/svh.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ mod svh_visitor {
247247
SawExprAssignOp(ast::BinOp),
248248
SawExprIndex,
249249
SawExprSlice,
250+
SawExprRange,
250251
SawExprPath,
251252
SawExprAddrOf(ast::Mutability),
252253
SawExprRet,
@@ -280,6 +281,7 @@ mod svh_visitor {
280281
ExprTupField(_, id) => SawExprTupField(id.node),
281282
ExprIndex(..) => SawExprIndex,
282283
ExprSlice(..) => SawExprSlice,
284+
ExprRange(..) => SawExprRange,
283285
ExprPath(..) => SawExprPath,
284286
ExprAddrOf(m, _) => SawExprAddrOf(m),
285287
ExprBreak(id) => SawExprBreak(id.map(content)),

src/librustc_trans/trans/debuginfo.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3494,6 +3494,11 @@ fn populate_scope_map(cx: &CrateContext,
34943494
end.as_ref().map(|x| walk_expr(cx, &**x, scope_stack, scope_map));
34953495
}
34963496

3497+
ast::ExprRange(..) => {
3498+
cx.sess().span_bug(exp.span, "debuginfo::populate_scope_map() - \
3499+
Found unexpanded range.");
3500+
}
3501+
34973502
ast::ExprVec(ref init_expressions) |
34983503
ast::ExprTup(ref init_expressions) => {
34993504
for ie in init_expressions.iter() {

src/librustc_typeck/check/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4278,6 +4278,10 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
42784278
}
42794279
}
42804280
}
4281+
ast::ExprRange(..) => {
4282+
tcx.sess.span_bug(expr.span, "non-desugared range");
4283+
}
4284+
42814285
}
42824286

42834287
debug!("type of expr({}) {} is...", expr.id,

src/libsyntax/ast.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -724,6 +724,7 @@ pub enum Expr_ {
724724
ExprTupField(P<Expr>, Spanned<uint>),
725725
ExprIndex(P<Expr>, P<Expr>),
726726
ExprSlice(P<Expr>, Option<P<Expr>>, Option<P<Expr>>, Mutability),
727+
ExprRange(P<Expr>, Option<P<Expr>>),
727728

728729
/// Variable reference, possibly containing `::` and/or
729730
/// type parameters, e.g. foo::bar::<baz>

src/libsyntax/fold.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1390,6 +1390,10 @@ pub fn noop_fold_expr<T: Folder>(Expr {id, node, span}: Expr, folder: &mut T) ->
13901390
e2.map(|x| folder.fold_expr(x)),
13911391
m)
13921392
}
1393+
ExprRange(e1, e2) => {
1394+
ExprRange(folder.fold_expr(e1),
1395+
e2.map(|x| folder.fold_expr(x)))
1396+
}
13931397
ExprPath(pth) => ExprPath(folder.fold_path(pth)),
13941398
ExprBreak(opt_ident) => ExprBreak(opt_ident.map(|x| folder.fold_ident(x))),
13951399
ExprAgain(opt_ident) => ExprAgain(opt_ident.map(|x| folder.fold_ident(x))),

0 commit comments

Comments
 (0)