diff --git a/src/librustc_trans/trans/controlflow.rs b/src/librustc_trans/trans/controlflow.rs index ea5eef48257..e6cd44676ce 100644 --- a/src/librustc_trans/trans/controlflow.rs +++ b/src/librustc_trans/trans/controlflow.rs @@ -339,7 +339,7 @@ pub fn trans_ret<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, let mut bcx = bcx; let dest = match (fcx.llretslotptr.get(), retval_expr) { (Some(_), Some(retval_expr)) => { - let ret_ty = expr_ty(bcx, &*retval_expr); + let ret_ty = expr_ty_adjusted(bcx, &*retval_expr); expr::SaveIn(fcx.get_ret_slot(bcx, ty::FnConverging(ret_ty), "ret_slot")) } _ => expr::Ignore, diff --git a/src/test/run-pass/issue22346.rs b/src/test/run-pass/issue22346.rs new file mode 100644 index 00000000000..3193e5c5fc2 --- /dev/null +++ b/src/test/run-pass/issue22346.rs @@ -0,0 +1,17 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// This used to cause an ICE because the retslot for the "return" had the wrong type +fn testcase<'a>() -> Box + 'a> { + return Box::new(range(0, 3).map(|i| { return i; })); +} + +fn main() { +}