Merge pull request #680 from RalfJung/miri-unsized

test calling Box<dyn FnOnce>
This commit is contained in:
Ralf Jung 2019-04-11 23:18:43 +02:00 committed by GitHub
commit 4eac25ce47
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 12 deletions

View file

@ -1 +1 @@
f717b58dd70829f105960a071c7992b440720482
3de0106789468b211bcc3a25c09c0cf07119186d

View file

@ -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);
}
}
}

View file

@ -1,4 +1,3 @@
// ignore-test FIXME ignored to let https://github.com/rust-lang/rust/pull/59119 land
#![feature(
async_await,
await_macro,
@ -6,7 +5,7 @@
)]
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 {
@ -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));
}

View file

@ -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);
}