Skip to content

Commit e27a85c

Browse files
committed
---
yaml --- r: 167261 b: refs/heads/try c: 4e2afb0 h: refs/heads/master i: 167259: e51e8fa v: v3
1 parent 4562656 commit e27a85c

File tree

19 files changed

+255
-320
lines changed

19 files changed

+255
-320
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 023dfb0c898d851dee6ace2f8339b73b5287136b
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 023dfb0c898d851dee6ace2f8339b73b5287136b
5-
refs/heads/try: ed8f5039115308ca9d5591126e4d8a77864d4730
5+
refs/heads/try: 4e2afb0052618ca3d758fffd0cf50559be774391
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
88
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596

branches/try/src/libcore/slice.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -990,7 +990,7 @@ impl<'a, T, P> Iterator<&'a mut [T]> for MutSplits<'a, T, P> where P: FnMut(&T)
990990
Some(idx) => {
991991
let tmp = mem::replace(&mut self.v, &mut []);
992992
let (head, tail) = tmp.split_at_mut(idx);
993-
self.v = tail[mut 1..];
993+
self.v = tail.slice_from_mut(1);
994994
Some(head)
995995
}
996996
}
@@ -1026,7 +1026,7 @@ impl<'a, T, P> DoubleEndedIterator<&'a mut [T]> for MutSplits<'a, T, P> where
10261026
let tmp = mem::replace(&mut self.v, &mut []);
10271027
let (head, tail) = tmp.split_at_mut(idx);
10281028
self.v = head;
1029-
Some(tail[mut 1..])
1029+
Some(tail.slice_from_mut(1))
10301030
}
10311031
}
10321032
}

branches/try/src/librustc/middle/cfg/construct.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -432,13 +432,6 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
432432
self.call(expr, pred, &**l, Some(&**r).into_iter())
433433
}
434434

435-
ast::ExprSlice(ref base, ref start, ref end, _) => {
436-
self.call(expr,
437-
pred,
438-
&**base,
439-
start.iter().chain(end.iter()).map(|x| &**x))
440-
}
441-
442435
ast::ExprRange(ref start, ref end) => {
443436
let fields = start.as_ref().map(|e| &**e).into_iter()
444437
.chain(end.as_ref().map(|e| &**e).into_iter());

branches/try/src/librustc/middle/expr_use_visitor.rs

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -431,24 +431,31 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
431431
}
432432

433433
ast::ExprIndex(ref lhs, ref rhs) => { // lhs[rhs]
434-
if !self.walk_overloaded_operator(expr, &**lhs, vec![&**rhs], PassArgs::ByRef) {
435-
self.select_from_expr(&**lhs);
436-
self.consume_expr(&**rhs);
434+
match rhs.node {
435+
ast::ExprRange(ref start, ref end) => {
436+
// Hacked slicing syntax (KILLME).
437+
let args = match (start, end) {
438+
(&Some(ref e1), &Some(ref e2)) => vec![&**e1, &**e2],
439+
(&Some(ref e), &None) => vec![&**e],
440+
(&None, &Some(ref e)) => vec![&**e],
441+
(&None, &None) => Vec::new()
442+
};
443+
let overloaded =
444+
self.walk_overloaded_operator(expr, &**lhs, args, PassArgs::ByRef);
445+
assert!(overloaded);
446+
}
447+
_ => {
448+
if !self.walk_overloaded_operator(expr,
449+
&**lhs,
450+
vec![&**rhs],
451+
PassArgs::ByRef) {
452+
self.select_from_expr(&**lhs);
453+
self.consume_expr(&**rhs);
454+
}
455+
}
437456
}
438457
}
439458

440-
ast::ExprSlice(ref base, ref start, ref end, _) => { // base[start..end]
441-
let args = match (start, end) {
442-
(&Some(ref e1), &Some(ref e2)) => vec![&**e1, &**e2],
443-
(&Some(ref e), &None) => vec![&**e],
444-
(&None, &Some(ref e)) => vec![&**e],
445-
(&None, &None) => Vec::new()
446-
};
447-
let overloaded =
448-
self.walk_overloaded_operator(expr, &**base, args, PassArgs::ByRef);
449-
assert!(overloaded);
450-
}
451-
452459
ast::ExprRange(ref start, ref end) => {
453460
start.as_ref().map(|e| self.consume_expr(&**e));
454461
end.as_ref().map(|e| self.consume_expr(&**e));

branches/try/src/librustc/middle/liveness.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ fn visit_expr(ir: &mut IrMaps, expr: &Expr) {
514514
ast::ExprBlock(..) | ast::ExprAssign(..) | ast::ExprAssignOp(..) |
515515
ast::ExprMac(..) | ast::ExprStruct(..) | ast::ExprRepeat(..) |
516516
ast::ExprParen(..) | ast::ExprInlineAsm(..) | ast::ExprBox(..) |
517-
ast::ExprSlice(..) | ast::ExprRange(..) => {
517+
ast::ExprRange(..) => {
518518
visit::walk_expr(ir, expr);
519519
}
520520
}
@@ -1191,12 +1191,6 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
11911191
self.propagate_through_expr(&**l, r_succ)
11921192
}
11931193

1194-
ast::ExprSlice(ref e1, ref e2, ref e3, _) => {
1195-
let succ = e3.as_ref().map_or(succ, |e| self.propagate_through_expr(&**e, succ));
1196-
let succ = e2.as_ref().map_or(succ, |e| self.propagate_through_expr(&**e, succ));
1197-
self.propagate_through_expr(&**e1, succ)
1198-
}
1199-
12001194
ast::ExprRange(ref e1, ref e2) => {
12011195
let succ = e2.as_ref().map_or(succ, |e| self.propagate_through_expr(&**e, succ));
12021196
e1.as_ref().map_or(succ, |e| self.propagate_through_expr(&**e, succ))
@@ -1495,7 +1489,7 @@ fn check_expr(this: &mut Liveness, expr: &Expr) {
14951489
ast::ExprBlock(..) | ast::ExprMac(..) | ast::ExprAddrOf(..) |
14961490
ast::ExprStruct(..) | ast::ExprRepeat(..) | ast::ExprParen(..) |
14971491
ast::ExprClosure(..) | ast::ExprPath(..) | ast::ExprBox(..) |
1498-
ast::ExprSlice(..) | ast::ExprRange(..) => {
1492+
ast::ExprRange(..) => {
14991493
visit::walk_expr(this, expr);
15001494
}
15011495
ast::ExprIfLet(..) => {

branches/try/src/librustc/middle/mem_categorization.rs

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -500,21 +500,29 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
500500
self.cat_tup_field(expr, base_cmt, idx.node, expr_ty)
501501
}
502502

503-
ast::ExprIndex(ref base, _) => {
504-
let method_call = ty::MethodCall::expr(expr.id());
505-
match self.typer.node_method_ty(method_call) {
506-
Some(method_ty) => {
507-
// If this is an index implemented by a method call, then it will
508-
// include an implicit deref of the result.
509-
let ret_ty = ty::ty_fn_ret(method_ty).unwrap();
510-
self.cat_deref(expr,
511-
self.cat_rvalue_node(expr.id(),
512-
expr.span(),
513-
ret_ty), 1, true)
503+
ast::ExprIndex(ref base, ref idx) => {
504+
match idx.node {
505+
ast::ExprRange(..) => {
506+
// Slicing syntax special case (KILLME).
507+
self.cat_rvalue_node(expr.id(), expr.span(), expr_ty)
514508
}
515-
None => {
516-
let base_cmt = self.cat_expr(&**base);
517-
self.cat_index(expr, base_cmt)
509+
_ => {
510+
let method_call = ty::MethodCall::expr(expr.id());
511+
match self.typer.node_method_ty(method_call) {
512+
Some(method_ty) => {
513+
// If this is an index implemented by a method call, then it will
514+
// include an implicit deref of the result.
515+
let ret_ty = ty::ty_fn_ret(method_ty).unwrap();
516+
self.cat_deref(expr,
517+
self.cat_rvalue_node(expr.id(),
518+
expr.span(),
519+
ret_ty), 1, true)
520+
}
521+
None => {
522+
let base_cmt = if_ok!(self.cat_expr(&**base));
523+
self.cat_index(expr, base_cmt)
524+
}
525+
}
518526
}
519527
}
520528
}
@@ -531,7 +539,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
531539
ast::ExprAddrOf(..) | ast::ExprCall(..) |
532540
ast::ExprAssign(..) | ast::ExprAssignOp(..) |
533541
ast::ExprClosure(..) | ast::ExprRet(..) |
534-
ast::ExprUnary(..) | ast::ExprSlice(..) | ast::ExprRange(..) |
542+
ast::ExprUnary(..) | ast::ExprRange(..) |
535543
ast::ExprMethodCall(..) | ast::ExprCast(..) |
536544
ast::ExprVec(..) | ast::ExprTup(..) | ast::ExprIf(..) |
537545
ast::ExprBinary(..) | ast::ExprWhile(..) |

branches/try/src/librustc/middle/ty.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4322,9 +4322,6 @@ pub fn expr_kind(tcx: &ctxt, expr: &ast::Expr) -> ExprKind {
43224322
// the index method invoked for `a[i]` always yields an `&T`
43234323
ast::ExprIndex(..) => LvalueExpr,
43244324

4325-
// the slice method invoked for `a[..]` always yields an `&T`
4326-
ast::ExprSlice(..) => LvalueExpr,
4327-
43284325
// `for` loops are statements
43294326
ast::ExprForLoop(..) => RvalueStmtExpr,
43304327

@@ -4389,8 +4386,7 @@ pub fn expr_kind(tcx: &ctxt, expr: &ast::Expr) -> ExprKind {
43894386
ast::ExprUnary(ast::UnDeref, _) |
43904387
ast::ExprField(..) |
43914388
ast::ExprTupField(..) |
4392-
ast::ExprIndex(..) |
4393-
ast::ExprSlice(..) => {
4389+
ast::ExprIndex(..) => {
43944390
LvalueExpr
43954391
}
43964392

branches/try/src/librustc_back/svh.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,6 @@ mod svh_visitor {
246246
SawExprAssign,
247247
SawExprAssignOp(ast::BinOp),
248248
SawExprIndex,
249-
SawExprSlice,
250249
SawExprRange,
251250
SawExprPath,
252251
SawExprAddrOf(ast::Mutability),
@@ -280,7 +279,6 @@ mod svh_visitor {
280279
ExprField(_, id) => SawExprField(content(id.node)),
281280
ExprTupField(_, id) => SawExprTupField(id.node),
282281
ExprIndex(..) => SawExprIndex,
283-
ExprSlice(..) => SawExprSlice,
284282
ExprRange(..) => SawExprRange,
285283
ExprPath(..) => SawExprPath,
286284
ExprAddrOf(m, _) => SawExprAddrOf(m),

branches/try/src/librustc_trans/trans/cleanup.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ use trans::common;
2424
use trans::common::{Block, FunctionContext, ExprId, NodeInfo};
2525
use trans::debuginfo;
2626
use trans::glue;
27-
use middle::region;
27+
// Temporary due to slicing syntax hacks (KILLME)
28+
//use middle::region;
2829
use trans::type_::Type;
2930
use middle::ty::{mod, Ty};
3031
use std::fmt;
@@ -128,15 +129,16 @@ impl<'blk, 'tcx> CleanupMethods<'blk, 'tcx> for FunctionContext<'blk, 'tcx> {
128129
// excluding id's that correspond to closure bodies only). For
129130
// now we just say that if there is already an AST scope on the stack,
130131
// this new AST scope had better be its immediate child.
131-
let top_scope = self.top_ast_scope();
132+
// Temporarily removed due to slicing syntax hacks (KILLME).
133+
/*let top_scope = self.top_ast_scope();
132134
if top_scope.is_some() {
133135
assert_eq!(self.ccx
134136
.tcx()
135137
.region_maps
136138
.opt_encl_scope(region::CodeExtent::from_node_id(debug_loc.id))
137139
.map(|s|s.node_id()),
138140
top_scope);
139-
}
141+
}*/
140142

141143
self.push_scope(CleanupScope::new(AstScopeKind(debug_loc.id),
142144
Some(debug_loc)));

branches/try/src/librustc_trans/trans/debuginfo.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3533,18 +3533,12 @@ fn create_scope_map(cx: &CrateContext,
35333533
}
35343534

35353535
ast::ExprAssignOp(_, ref lhs, ref rhs) |
3536-
ast::ExprIndex(ref lhs, ref rhs) |
3536+
ast::ExprIndex(ref lhs, ref rhs) |
35373537
ast::ExprBinary(_, ref lhs, ref rhs) => {
35383538
walk_expr(cx, &**lhs, scope_stack, scope_map);
35393539
walk_expr(cx, &**rhs, scope_stack, scope_map);
35403540
}
35413541

3542-
ast::ExprSlice(ref base, ref start, ref end, _) => {
3543-
walk_expr(cx, &**base, scope_stack, scope_map);
3544-
start.as_ref().map(|x| walk_expr(cx, &**x, scope_stack, scope_map));
3545-
end.as_ref().map(|x| walk_expr(cx, &**x, scope_stack, scope_map));
3546-
}
3547-
35483542
ast::ExprRange(ref start, ref end) => {
35493543
start.as_ref().map(|e| walk_expr(cx, &**e, scope_stack, scope_map));
35503544
end.as_ref().map(|e| walk_expr(cx, &**e, scope_stack, scope_map));

branches/try/src/librustc_trans/trans/expr.rs

Lines changed: 34 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -585,36 +585,40 @@ fn trans_datum_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
585585
trans_rec_tup_field(bcx, &**base, idx.node)
586586
}
587587
ast::ExprIndex(ref base, ref idx) => {
588-
trans_index(bcx, expr, &**base, &**idx, MethodCall::expr(expr.id))
589-
}
590-
ast::ExprSlice(ref base, ref start, ref end, _) => {
591-
let _icx = push_ctxt("trans_slice");
592-
let ccx = bcx.ccx();
593-
594-
let method_call = MethodCall::expr(expr.id);
595-
let method_ty = ccx.tcx()
596-
.method_map
597-
.borrow()
598-
.get(&method_call)
599-
.map(|method| method.ty);
600-
let base_datum = unpack_datum!(bcx, trans(bcx, &**base));
601-
602-
let mut args = vec![];
603-
start.as_ref().map(|e| args.push((unpack_datum!(bcx, trans(bcx, &**e)), e.id)));
604-
end.as_ref().map(|e| args.push((unpack_datum!(bcx, trans(bcx, &**e)), e.id)));
605-
606-
let result_ty = ty::ty_fn_ret(monomorphize_type(bcx, method_ty.unwrap())).unwrap();
607-
let scratch = rvalue_scratch_datum(bcx, result_ty, "trans_slice");
608-
609-
unpack_result!(bcx,
610-
trans_overloaded_op(bcx,
611-
expr,
612-
method_call,
613-
base_datum,
614-
args,
615-
Some(SaveIn(scratch.val)),
616-
true));
617-
DatumBlock::new(bcx, scratch.to_expr_datum())
588+
match idx.node {
589+
ast::ExprRange(ref start, ref end) => {
590+
// Special case for slicing syntax (KILLME).
591+
let _icx = push_ctxt("trans_slice");
592+
let ccx = bcx.ccx();
593+
594+
let method_call = MethodCall::expr(expr.id);
595+
let method_ty = ccx.tcx()
596+
.method_map
597+
.borrow()
598+
.get(&method_call)
599+
.map(|method| method.ty);
600+
let base_datum = unpack_datum!(bcx, trans(bcx, &**base));
601+
602+
let mut args = vec![];
603+
start.as_ref().map(|e| args.push((unpack_datum!(bcx, trans(bcx, &**e)), e.id)));
604+
end.as_ref().map(|e| args.push((unpack_datum!(bcx, trans(bcx, &**e)), e.id)));
605+
606+
let result_ty = ty::ty_fn_ret(monomorphize_type(bcx,
607+
method_ty.unwrap())).unwrap();
608+
let scratch = rvalue_scratch_datum(bcx, result_ty, "trans_slice");
609+
610+
unpack_result!(bcx,
611+
trans_overloaded_op(bcx,
612+
expr,
613+
method_call,
614+
base_datum,
615+
args,
616+
Some(SaveIn(scratch.val)),
617+
true));
618+
DatumBlock::new(bcx, scratch.to_expr_datum())
619+
}
620+
_ => trans_index(bcx, expr, &**base, &**idx, MethodCall::expr(expr.id))
621+
}
618622
}
619623
ast::ExprBox(_, ref contents) => {
620624
// Special case for `Box<T>`

branches/try/src/librustc_typeck/check/method/confirm.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,6 @@ impl<'a,'tcx> ConfirmContext<'a,'tcx> {
488488
ast::ExprParen(ref expr) |
489489
ast::ExprField(ref expr, _) |
490490
ast::ExprTupField(ref expr, _) |
491-
ast::ExprSlice(ref expr, _, _, _) |
492491
ast::ExprIndex(ref expr, _) |
493492
ast::ExprUnary(ast::UnDeref, ref expr) => exprs.push(&**expr),
494493
_ => break,

0 commit comments

Comments
 (0)