Skip to content

Commit

Permalink
Merge pull request #680 from RalfJung/miri-unsized
Browse files Browse the repository at this point in the history
test calling Box<dyn FnOnce>
  • Loading branch information
RalfJung authored Apr 11, 2019
2 parents 2dc6e8b + 8235f56 commit 4eac25c
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
2 changes: 1 addition & 1 deletion rust-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
f717b58dd70829f105960a071c7992b440720482
3de0106789468b211bcc3a25c09c0cf07119186d
4 changes: 1 addition & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,9 +270,7 @@ pub fn eval_main<'a, 'tcx: 'a>(
trace!("Frame {}", i);
trace!(" return: {:#?}", frame.return_place);
for (i, local) in frame.locals.iter().enumerate() {
if let Ok(local) = local.access() {
trace!(" local {}: {:?}", i, local);
}
trace!(" local {}: {:?}", i, local.value);
}
}
}
Expand Down
16 changes: 8 additions & 8 deletions tests/run-pass/async-fn.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
// ignore-test FIXME ignored to let https://github.com/rust-lang/rust/pull/59119 land
#![feature(
async_await,
await_macro,
futures_api,
)]

use std::{future::Future, pin::Pin, task::Poll, ptr};
use std::task::{Waker, RawWaker, RawWakerVTable};
use std::task::{Waker, RawWaker, RawWakerVTable, Context};

// See if we can run a basic `async fn`
pub async fn foo(x: &u32, y: u32) -> u32 {
Expand All @@ -27,15 +26,16 @@ fn raw_waker_wake(_this: *const ()) {
}
fn raw_waker_drop(_this: *const ()) {}

static RAW_WAKER: RawWakerVTable = RawWakerVTable {
clone: raw_waker_clone,
wake: raw_waker_wake,
drop: raw_waker_drop,
};
static RAW_WAKER: RawWakerVTable = RawWakerVTable::new(
raw_waker_clone,
raw_waker_wake,
raw_waker_drop,
);

fn main() {
let x = 5;
let mut fut = foo(&x, 7);
let waker = unsafe { Waker::new_unchecked(RawWaker::new(ptr::null(), &RAW_WAKER)) };
assert_eq!(unsafe { Pin::new_unchecked(&mut fut) }.poll(&waker), Poll::Ready(31));
let mut context = Context::from_waker(&waker);
assert_eq!(unsafe { Pin::new_unchecked(&mut fut) }.poll(&mut context), Poll::Ready(31));
}
5 changes: 5 additions & 0 deletions tests/run-pass/closures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,14 @@ fn fn_once_closure_with_multiple_args() -> i64 {
}
}

fn boxed(f: Box<dyn FnOnce() -> i32>) -> i32 {
f()
}

fn main() {
assert_eq!(simple(), 12);
assert_eq!(crazy_closure(), (84, 10, 10));
assert_eq!(closure_arg_adjustment_problem(), 3);
assert_eq!(fn_once_closure_with_multiple_args(), 6);
assert_eq!(boxed(Box::new({let x = 13; move || x})), 13);
}

0 comments on commit 4eac25c

Please sign in to comment.