Skip to content

Commit ef7874a

Browse files
author
Jorge Aparicio
committed
---
yaml --- r: 177659 b: refs/heads/tmp c: a873316 h: refs/heads/master i: 177657: d152668 177655: 2611a77 v: v3
1 parent 91836a8 commit ef7874a

File tree

10 files changed

+6
-303
lines changed

10 files changed

+6
-303
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@ refs/heads/building: 126db549b038c84269a1e4fe46f051b2c15d6970
3434
refs/heads/beta: 44a287e6eb22ec3c2a687fc156813577464017f7
3535
refs/heads/windistfix: 7608dbad651f02e837ed05eef3d74a6662a6e928
3636
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
37-
refs/heads/tmp: acb8c1aaa6f3aa46cc3abf9ccc77b4882d778f9c
37+
refs/heads/tmp: a8733162772feec5f498427ea10d869272d164ab

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
263263
self.tcx.sess.span_bug(expr.span, "non-desugared ExprWhileLet");
264264
}
265265

266-
ast::ExprForLoop(ref pat, ref head, ref body, _) => {
266+
ast::ExprForLoop(..) => {
267267
self.tcx.sess.span_bug(expr.span, "non-desugared ExprForLoop");
268268
}
269269

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
537537
self.tcx().sess.span_bug(expr.span, "non-desugared ExprWhileLet");
538538
}
539539

540-
ast::ExprForLoop(ref pat, ref head, ref blk, _) => {
540+
ast::ExprForLoop(..) => {
541541
self.tcx().sess.span_bug(expr.span, "non-desugared ExprForLoop");
542542
}
543543

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

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,6 @@ enum LoopKind<'a> {
135135
LoopLoop,
136136
/// A `while` loop, with the given expression as condition.
137137
WhileLoop(&'a Expr),
138-
/// A `for` loop, with the given pattern to bind.
139-
ForLoop(&'a ast::Pat),
140138
}
141139

142140
#[derive(Copy, PartialEq)]
@@ -490,7 +488,7 @@ fn visit_expr(ir: &mut IrMaps, expr: &Expr) {
490488
ast::ExprWhileLet(..) => {
491489
ir.tcx.sess.span_bug(expr.span, "non-desugared ExprWhileLet");
492490
}
493-
ast::ExprForLoop(ref pat, _, _, _) => {
491+
ast::ExprForLoop(..) => {
494492
ir.tcx.sess.span_bug(expr.span, "non-desugared ExprForLoop");
495493
}
496494
ast::ExprBinary(op, _, _) if ast_util::lazy_binop(op.node) => {
@@ -1023,7 +1021,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
10231021
self.ir.tcx.sess.span_bug(expr.span, "non-desugared ExprWhileLet");
10241022
}
10251023

1026-
ast::ExprForLoop(ref pat, ref head, ref blk, _) => {
1024+
ast::ExprForLoop(..) => {
10271025
self.ir.tcx.sess.span_bug(expr.span, "non-desugared ExprForLoop");
10281026
}
10291027

@@ -1361,7 +1359,6 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
13611359

13621360
let cond_ln = match kind {
13631361
LoopLoop => ln,
1364-
ForLoop(ref pat) => self.define_bindings_in_pat(*pat, ln),
13651362
WhileLoop(ref cond) => self.propagate_through_expr(&**cond, ln),
13661363
};
13671364
let body_ln = self.with_loop_nodes(expr.id, succ, ln, |this| {
@@ -1374,9 +1371,6 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
13741371

13751372
let new_cond_ln = match kind {
13761373
LoopLoop => ln,
1377-
ForLoop(ref pat) => {
1378-
self.define_bindings_in_pat(*pat, ln)
1379-
}
13801374
WhileLoop(ref cond) => {
13811375
self.propagate_through_expr(&**cond, ln)
13821376
}

branches/tmp/src/librustc_back/svh.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,6 @@ mod svh_visitor {
252252
SawExprStruct,
253253
SawExprRepeat,
254254
SawExprParen,
255-
SawExprForLoop,
256255
}
257256

258257
fn saw_expr<'a>(node: &'a Expr_) -> SawExprComponent<'a> {

branches/tmp/src/librustc_resolve/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ use rustc::util::lev_distance::lev_distance;
6868

6969
use syntax::ast::{Arm, BindByRef, BindByValue, BindingMode, Block, Crate, CrateNum};
7070
use syntax::ast::{DefId, Expr, ExprAgain, ExprBreak, ExprField};
71-
use syntax::ast::{ExprClosure, ExprForLoop, ExprLoop, ExprWhile, ExprMethodCall};
71+
use syntax::ast::{ExprClosure, ExprLoop, ExprWhile, ExprMethodCall};
7272
use syntax::ast::{ExprPath, ExprQPath, ExprStruct, FnDecl};
7373
use syntax::ast::{ForeignItemFn, ForeignItemStatic, Generics};
7474
use syntax::ast::{Ident, ImplItem, Item, ItemConst, ItemEnum, ItemExternCrate};

branches/tmp/src/librustc_trans/trans/_match.rs

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1537,31 +1537,6 @@ pub fn store_arg<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
15371537
}
15381538
}
15391539

1540-
/// Generates code for the pattern binding in a `for` loop like
1541-
/// `for <pat> in <expr> { ... }`.
1542-
pub fn store_for_loop_binding<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
1543-
pat: &ast::Pat,
1544-
llvalue: ValueRef,
1545-
body_scope: cleanup::ScopeId)
1546-
-> Block<'blk, 'tcx> {
1547-
let _icx = push_ctxt("match::store_for_loop_binding");
1548-
1549-
if simple_identifier(&*pat).is_some() &&
1550-
bcx.sess().opts.debuginfo != FullDebugInfo {
1551-
// Generate nicer LLVM for the common case of a `for` loop pattern
1552-
// like `for x in blahblah { ... }`.
1553-
let binding_type = node_id_type(bcx, pat.id);
1554-
bcx.fcx.lllocals.borrow_mut().insert(pat.id,
1555-
Datum::new(llvalue,
1556-
binding_type,
1557-
Lvalue));
1558-
return bcx
1559-
}
1560-
1561-
// General path. Copy out the values that are used in the pattern.
1562-
bind_irrefutable_pat(bcx, pat, llvalue, body_scope)
1563-
}
1564-
15651540
fn mk_binding_alloca<'blk, 'tcx, A, F>(bcx: Block<'blk, 'tcx>,
15661541
p_id: ast::NodeId,
15671542
ident: &ast::Ident,

branches/tmp/src/librustc_trans/trans/controlflow.rs

Lines changed: 0 additions & 136 deletions
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,19 @@
1111
use llvm::ValueRef;
1212
use middle::def;
1313
use middle::lang_items::{PanicFnLangItem, PanicBoundsCheckFnLangItem};
14-
use trans::_match;
15-
use trans::adt;
1614
use trans::base::*;
1715
use trans::build::*;
1816
use trans::callee;
1917
use trans::cleanup::CleanupMethods;
2018
use trans::cleanup;
2119
use trans::common::*;
2220
use trans::consts;
23-
use trans::datum;
2421
use trans::debuginfo;
2522
use trans::debuginfo::{DebugLoc, ToDebugLoc};
2623
use trans::expr;
27-
use trans::meth;
28-
use trans::type_::Type;
2924
use trans;
3025
use middle::ty;
31-
use middle::ty::MethodCall;
3226
use util::ppaux::Repr;
33-
use util::ppaux;
3427

3528
use syntax::ast;
3629
use syntax::ast::Ident;
@@ -259,135 +252,6 @@ pub fn trans_while<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
259252
return next_bcx_in;
260253
}
261254

262-
/// Translates a `for` loop.
263-
pub fn trans_for<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
264-
loop_info: NodeIdAndSpan,
265-
pat: &ast::Pat,
266-
head: &ast::Expr,
267-
body: &ast::Block)
268-
-> Block<'blk, 'tcx>
269-
{
270-
let _icx = push_ctxt("trans_for");
271-
272-
// bcx
273-
// |
274-
// loopback_bcx_in <-------+
275-
// | |
276-
// loopback_bcx_out |
277-
// | | |
278-
// | body_bcx_in |
279-
// cleanup_blk | |
280-
// | body_bcx_out --+
281-
// next_bcx_in
282-
283-
// Codegen the head to create the iterator value.
284-
let iterator_datum =
285-
unpack_datum!(bcx, expr::trans_to_lvalue(bcx, head, "for_head"));
286-
let iterator_type = node_id_type(bcx, head.id);
287-
debug!("iterator type is {}, datum type is {}",
288-
ppaux::ty_to_string(bcx.tcx(), iterator_type),
289-
ppaux::ty_to_string(bcx.tcx(), iterator_datum.ty));
290-
291-
let lliterator = load_ty(bcx, iterator_datum.val, iterator_datum.ty);
292-
293-
// Create our basic blocks and set up our loop cleanups.
294-
let next_bcx_in = bcx.fcx.new_id_block("for_exit", loop_info.id);
295-
let loopback_bcx_in = bcx.fcx.new_id_block("for_loopback", head.id);
296-
let body_bcx_in = bcx.fcx.new_id_block("for_body", body.id);
297-
bcx.fcx.push_loop_cleanup_scope(loop_info.id,
298-
[next_bcx_in, loopback_bcx_in]);
299-
Br(bcx, loopback_bcx_in.llbb, DebugLoc::None);
300-
let cleanup_llbb = bcx.fcx.normal_exit_block(loop_info.id,
301-
cleanup::EXIT_BREAK);
302-
303-
// Set up the method call (to `.next()`).
304-
let method_call = MethodCall::expr(loop_info.id);
305-
let method_type = (*loopback_bcx_in.tcx()
306-
.method_map
307-
.borrow())[method_call]
308-
.ty;
309-
let method_type = monomorphize_type(loopback_bcx_in, method_type);
310-
let method_result_type =
311-
ty::assert_no_late_bound_regions( // LB regions are instantiated in invoked methods
312-
loopback_bcx_in.tcx(), &ty::ty_fn_ret(method_type)).unwrap();
313-
let option_cleanup_scope = body_bcx_in.fcx.push_custom_cleanup_scope();
314-
let option_cleanup_scope_id = cleanup::CustomScope(option_cleanup_scope);
315-
316-
// Compile the method call (to `.next()`).
317-
let mut loopback_bcx_out = loopback_bcx_in;
318-
let option_datum =
319-
unpack_datum!(loopback_bcx_out,
320-
datum::lvalue_scratch_datum(loopback_bcx_out,
321-
method_result_type,
322-
"loop_option",
323-
false,
324-
option_cleanup_scope_id,
325-
(),
326-
|(), bcx, lloption| {
327-
let Result {
328-
bcx,
329-
val: _
330-
} = callee::trans_call_inner(bcx,
331-
Some(loop_info),
332-
method_type,
333-
|bcx, arg_cleanup_scope| {
334-
meth::trans_method_callee(
335-
bcx,
336-
method_call,
337-
None,
338-
arg_cleanup_scope)
339-
},
340-
callee::ArgVals(&[lliterator]),
341-
Some(expr::SaveIn(lloption)));
342-
bcx
343-
}));
344-
345-
// Check the discriminant; if the `None` case, exit the loop.
346-
let option_representation = adt::represent_type(loopback_bcx_out.ccx(),
347-
method_result_type);
348-
let lldiscriminant = adt::trans_get_discr(loopback_bcx_out,
349-
&*option_representation,
350-
option_datum.val,
351-
None);
352-
let i1_type = Type::i1(loopback_bcx_out.ccx());
353-
let llcondition = Trunc(loopback_bcx_out, lldiscriminant, i1_type);
354-
CondBr(loopback_bcx_out, llcondition, body_bcx_in.llbb, cleanup_llbb, DebugLoc::None);
355-
356-
// Now we're in the body. Unpack the `Option` value into the programmer-
357-
// supplied pattern.
358-
let llpayload = adt::trans_field_ptr(body_bcx_in,
359-
&*option_representation,
360-
option_datum.val,
361-
1,
362-
0);
363-
let binding_cleanup_scope = body_bcx_in.fcx.push_custom_cleanup_scope();
364-
let binding_cleanup_scope_id =
365-
cleanup::CustomScope(binding_cleanup_scope);
366-
let mut body_bcx_out =
367-
_match::store_for_loop_binding(body_bcx_in,
368-
pat,
369-
llpayload,
370-
binding_cleanup_scope_id);
371-
372-
debuginfo::create_for_loop_var_metadata(body_bcx_in, pat);
373-
374-
// Codegen the body.
375-
body_bcx_out = trans_block(body_bcx_out, body, expr::Ignore);
376-
body_bcx_out =
377-
body_bcx_out.fcx
378-
.pop_and_trans_custom_cleanup_scope(body_bcx_out,
379-
binding_cleanup_scope);
380-
body_bcx_out =
381-
body_bcx_out.fcx
382-
.pop_and_trans_custom_cleanup_scope(body_bcx_out,
383-
option_cleanup_scope);
384-
Br(body_bcx_out, loopback_bcx_in.llbb, DebugLoc::None);
385-
386-
// Codegen cleanups and leave.
387-
next_bcx_in.fcx.pop_loop_cleanup_scope(loop_info.id);
388-
next_bcx_in
389-
}
390-
391255
pub fn trans_loop<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
392256
loop_expr: &ast::Expr,
393257
body: &ast::Block)

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

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,48 +1053,6 @@ pub fn create_argument_metadata(bcx: Block, arg: &ast::Arg) {
10531053
})
10541054
}
10551055

1056-
/// Creates debug information for the given for-loop variable.
1057-
///
1058-
/// This function assumes that there's a datum for each pattern component of the
1059-
/// loop variable in `bcx.fcx.lllocals`.
1060-
/// Adds the created metadata nodes directly to the crate's IR.
1061-
pub fn create_for_loop_var_metadata(bcx: Block, pat: &ast::Pat) {
1062-
if bcx.unreachable.get() ||
1063-
fn_should_be_ignored(bcx.fcx) ||
1064-
bcx.sess().opts.debuginfo != FullDebugInfo {
1065-
return;
1066-
}
1067-
1068-
let def_map = &bcx.tcx().def_map;
1069-
let locals = bcx.fcx.lllocals.borrow();
1070-
1071-
pat_util::pat_bindings(def_map, pat, |_, node_id, span, var_ident| {
1072-
let datum = match locals.get(&node_id) {
1073-
Some(datum) => datum,
1074-
None => {
1075-
bcx.sess().span_bug(span,
1076-
format!("no entry in lllocals table for {}",
1077-
node_id).as_slice());
1078-
}
1079-
};
1080-
1081-
if unsafe { llvm::LLVMIsAAllocaInst(datum.val) } == ptr::null_mut() {
1082-
bcx.sess().span_bug(span, "debuginfo::create_for_loop_var_metadata() - \
1083-
Referenced variable location is not an alloca!");
1084-
}
1085-
1086-
let scope_metadata = scope_metadata(bcx.fcx, node_id, span);
1087-
1088-
declare_local(bcx,
1089-
var_ident.node,
1090-
datum.ty,
1091-
scope_metadata,
1092-
DirectVariable { alloca: datum.val },
1093-
LocalVariable,
1094-
span);
1095-
})
1096-
}
1097-
10981056
pub fn get_cleanup_debug_loc_for_ast_node<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
10991057
node_id: ast::NodeId,
11001058
node_span: Span,

0 commit comments

Comments
 (0)