Skip to content

Commit f673e98

Browse files
committed
auto merge of #20167 : michaelwoerister/rust/for-loop-var, r=alexcrichton
... really this time `:)` I went for the simpler fix after all since it turned out to become a bit too complicated to extract the current iteration value from its containing `Option` with the different memory layouts it can have. It's also what we already do for match bindings. I also extended the new test case to include the "simple identifier" case. Fixes #20127, fixes #19732
2 parents ead198c + 875a30c commit f673e98

File tree

5 files changed

+345
-72
lines changed

5 files changed

+345
-72
lines changed

src/librustc_trans/trans/_match.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1554,7 +1554,8 @@ pub fn store_for_loop_binding<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
15541554
-> Block<'blk, 'tcx> {
15551555
let _icx = push_ctxt("match::store_for_loop_binding");
15561556

1557-
if simple_identifier(&*pat).is_some() {
1557+
if simple_identifier(&*pat).is_some() &&
1558+
bcx.sess().opts.debuginfo != FullDebugInfo {
15581559
// Generate nicer LLVM for the common case of a `for` loop pattern
15591560
// like `for x in blahblah { ... }`.
15601561
let binding_type = node_id_type(bcx, pat.id);

src/librustc_trans/trans/controlflow.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,7 @@ pub fn trans_for<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
286286
debug!("iterator type is {}, datum type is {}",
287287
ppaux::ty_to_string(bcx.tcx(), iterator_type),
288288
ppaux::ty_to_string(bcx.tcx(), iterator_datum.ty));
289+
289290
let lliterator = load_ty(bcx, iterator_datum.val, iterator_datum.ty);
290291

291292
// Create our basic blocks and set up our loop cleanups.
@@ -365,6 +366,8 @@ pub fn trans_for<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
365366
llpayload,
366367
binding_cleanup_scope_id);
367368

369+
debuginfo::create_for_loop_var_metadata(body_bcx_in, pat);
370+
368371
// Codegen the body.
369372
body_bcx_out = trans_block(body_bcx_out, body, expr::Ignore);
370373
body_bcx_out =

0 commit comments

Comments
 (0)