diff --git a/rust-version b/rust-version index 2c98082bc1..eca1a2335c 100644 --- a/rust-version +++ b/rust-version @@ -1 +1 @@ -b17491c8f6d555386104dfd82004c01bfef09c95 +d26b41711282042c4ea0c5733e7332b07cfa4933 diff --git a/tests/fail/unaligned_pointers/unaligned_ref_addr_of.rs b/tests/fail/unaligned_pointers/unaligned_ref_addr_of.rs index 470420acd5..225feef728 100644 --- a/tests/fail/unaligned_pointers/unaligned_ref_addr_of.rs +++ b/tests/fail/unaligned_pointers/unaligned_ref_addr_of.rs @@ -1,6 +1,8 @@ // This should fail even without Stacked Borrows. //@compile-flags: -Zmiri-disable-stacked-borrows -Cdebug-assertions=no +#![allow(invalid_reference_casting)] // for u16 -> u32 + fn main() { // Try many times as this might work by chance. for _ in 0..20 { diff --git a/tests/pass/async-closure.rs b/tests/pass/async-closure.rs new file mode 100644 index 0000000000..e04acfc39c --- /dev/null +++ b/tests/pass/async-closure.rs @@ -0,0 +1,41 @@ +#![feature(async_closure, noop_waker, async_fn_traits)] + +use std::future::Future; +use std::pin::pin; +use std::task::*; + +pub fn block_on(fut: impl Future) -> T { + let mut fut = pin!(fut); + let ctx = &mut Context::from_waker(Waker::noop()); + + loop { + match fut.as_mut().poll(ctx) { + Poll::Pending => {} + Poll::Ready(t) => break t, + } + } +} + +#[rustfmt::skip] +async fn call_once(f: impl async FnOnce(DropMe)) { + f(DropMe("world")).await; +} + +#[derive(Debug)] +struct DropMe(&'static str); + +impl Drop for DropMe { + fn drop(&mut self) { + println!("{}", self.0); + } +} + +pub fn main() { + block_on(async { + let b = DropMe("hello"); + let async_closure = async move |a: DropMe| { + println!("{a:?} {b:?}"); + }; + call_once(async_closure).await; + }); +} diff --git a/tests/pass/async-closure.stdout b/tests/pass/async-closure.stdout new file mode 100644 index 0000000000..34cfdedc44 --- /dev/null +++ b/tests/pass/async-closure.stdout @@ -0,0 +1,3 @@ +DropMe("world") DropMe("hello") +world +hello