Skip to content

Commit

Permalink
Merge branch 'master' into libstd
Browse files Browse the repository at this point in the history
  • Loading branch information
oli-obk authored Aug 24, 2017
2 parents 9ede346 + f860ad8 commit 110d50e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/librustc_mir/interpret/eval_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
10 changes: 10 additions & 0 deletions tests/run-pass/closure-field-ty.rs
Original file line number Diff line number Diff line change
@@ -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);
}

0 comments on commit 110d50e

Please sign in to comment.