Merge branch 'master' into drop

This commit is contained in:
Oliver Schneider 2017-08-24 23:52:36 +02:00 committed by GitHub
commit fad1bc8b20
2 changed files with 15 additions and 0 deletions

View file

@ -1176,6 +1176,11 @@ impl<'a, 'tcx, M: Machine<'tcx>> EvalContext<'a, 'tcx, M> {
packed: false,
}),
ty::TyClosure(def_id, ref closure_substs) => Ok(TyAndPacked {
ty: closure_substs.upvar_tys(def_id, self.tcx).nth(field_index).unwrap(),
packed: false,
}),
_ => {
err!(Unimplemented(
format!("can't handle type: {:?}, {:?}", ty, ty.sty),

View file

@ -0,0 +1,10 @@
// miri issue #304
fn main() {
let mut y = 0;
{
let mut box_maybe_closure = Box::new(None);
*box_maybe_closure = Some(|| { y += 1; });
(box_maybe_closure.unwrap())();
}
assert_eq!(y, 1);
}