Skip to content

Commit 521f82e

Browse files
committed
Auto merge of rust-lang#26079 - eefriedman:emit-closure, r=nrc
This isn't a very clean fix, but I'm not sure what a better fix would look like. Fixes rust-lang#24779.
2 parents 02c33b6 + 2442f83 commit 521f82e

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

src/librustc_trans/trans/expr.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,12 @@ pub fn trans_into<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
139139
// have different types.
140140
let lldest = PointerCast(bcx, lldest, val_ty(global));
141141
memcpy_ty(bcx, lldest, global, expr_ty_adjusted(bcx, expr));
142+
return bcx;
142143
}
143-
// Don't do anything in the Ignore case, consts don't need drop.
144-
return bcx;
144+
// Even if we don't have a value to emit, and the expression
145+
// doesn't have any side-effects, we still have to translate the
146+
// body of any closures.
147+
// FIXME: Find a better way of handling this case.
145148
} else {
146149
// The only way we're going to see a `const` at this point is if
147150
// it prefers in-place instantiation, likely because it contains

src/test/run-pass/issue-24779.rs

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
fn main() {
12+
assert_eq!((||||42)()(), 42);
13+
}

0 commit comments

Comments
 (0)