Skip to content

Commit 4eac25c

Browse files
authored
Merge pull request #680 from RalfJung/miri-unsized
test calling Box<dyn FnOnce>
2 parents 2dc6e8b + 8235f56 commit 4eac25c

File tree

4 files changed

+15
-12
lines changed

4 files changed

+15
-12
lines changed

rust-version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
f717b58dd70829f105960a071c7992b440720482
1+
3de0106789468b211bcc3a25c09c0cf07119186d

src/lib.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -270,9 +270,7 @@ pub fn eval_main<'a, 'tcx: 'a>(
270270
trace!("Frame {}", i);
271271
trace!(" return: {:#?}", frame.return_place);
272272
for (i, local) in frame.locals.iter().enumerate() {
273-
if let Ok(local) = local.access() {
274-
trace!(" local {}: {:?}", i, local);
275-
}
273+
trace!(" local {}: {:?}", i, local.value);
276274
}
277275
}
278276
}

tests/run-pass/async-fn.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
// ignore-test FIXME ignored to let https://github.com/rust-lang/rust/pull/59119 land
21
#![feature(
32
async_await,
43
await_macro,
54
futures_api,
65
)]
76

87
use std::{future::Future, pin::Pin, task::Poll, ptr};
9-
use std::task::{Waker, RawWaker, RawWakerVTable};
8+
use std::task::{Waker, RawWaker, RawWakerVTable, Context};
109

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

30-
static RAW_WAKER: RawWakerVTable = RawWakerVTable {
31-
clone: raw_waker_clone,
32-
wake: raw_waker_wake,
33-
drop: raw_waker_drop,
34-
};
29+
static RAW_WAKER: RawWakerVTable = RawWakerVTable::new(
30+
raw_waker_clone,
31+
raw_waker_wake,
32+
raw_waker_drop,
33+
);
3534

3635
fn main() {
3736
let x = 5;
3837
let mut fut = foo(&x, 7);
3938
let waker = unsafe { Waker::new_unchecked(RawWaker::new(ptr::null(), &RAW_WAKER)) };
40-
assert_eq!(unsafe { Pin::new_unchecked(&mut fut) }.poll(&waker), Poll::Ready(31));
39+
let mut context = Context::from_waker(&waker);
40+
assert_eq!(unsafe { Pin::new_unchecked(&mut fut) }.poll(&mut context), Poll::Ready(31));
4141
}

tests/run-pass/closures.rs

+5
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,14 @@ fn fn_once_closure_with_multiple_args() -> i64 {
4040
}
4141
}
4242

43+
fn boxed(f: Box<dyn FnOnce() -> i32>) -> i32 {
44+
f()
45+
}
46+
4347
fn main() {
4448
assert_eq!(simple(), 12);
4549
assert_eq!(crazy_closure(), (84, 10, 10));
4650
assert_eq!(closure_arg_adjustment_problem(), 3);
4751
assert_eq!(fn_once_closure_with_multiple_args(), 6);
52+
assert_eq!(boxed(Box::new({let x = 13; move || x})), 13);
4853
}

0 commit comments

Comments
 (0)