From 945fae75971a6fbd1b962664c4c29c87de9b7bea Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Sun, 11 Feb 2024 22:09:28 +0000 Subject: [PATCH 1/4] Fix async closures in CTFE --- tests/pass/async-closure.rs | 40 +++++++++++++++++++++++++++++++++ tests/pass/async-closure.stdout | 3 +++ 2 files changed, 43 insertions(+) create mode 100644 tests/pass/async-closure.rs create mode 100644 tests/pass/async-closure.stdout diff --git a/tests/pass/async-closure.rs b/tests/pass/async-closure.rs new file mode 100644 index 0000000000..9b2fc2948b --- /dev/null +++ b/tests/pass/async-closure.rs @@ -0,0 +1,40 @@ +#![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, + } + } +} + +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 From c632c9d3c7f371aa189542934aea8d93fc08fa88 Mon Sep 17 00:00:00 2001 From: Urgau Date: Sun, 17 Dec 2023 18:40:49 +0100 Subject: [PATCH 2/4] Allow invalid ref casting in Miri unaligned_ref_addr_of test --- tests/fail/unaligned_pointers/unaligned_ref_addr_of.rs | 2 ++ 1 file changed, 2 insertions(+) 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 { From a22325c8e2cf1e36d5c50b463893163815a86c68 Mon Sep 17 00:00:00 2001 From: The Miri Conjob Bot Date: Tue, 13 Feb 2024 05:14:22 +0000 Subject: [PATCH 3/4] Preparing for merge from rustc --- rust-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-version b/rust-version index 2c98082bc1..eca1a2335c 100644 --- a/rust-version +++ b/rust-version @@ -1 +1 @@ -b17491c8f6d555386104dfd82004c01bfef09c95 +d26b41711282042c4ea0c5733e7332b07cfa4933 From 23459433fd059b7b29405632d8dad622f3fb33a2 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Tue, 13 Feb 2024 08:31:45 +0000 Subject: [PATCH 4/4] Prevent rustfmt from messing up experimental syntax --- tests/pass/async-closure.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/pass/async-closure.rs b/tests/pass/async-closure.rs index 9b2fc2948b..e04acfc39c 100644 --- a/tests/pass/async-closure.rs +++ b/tests/pass/async-closure.rs @@ -16,6 +16,7 @@ pub fn block_on(fut: impl Future) -> T { } } +#[rustfmt::skip] async fn call_once(f: impl async FnOnce(DropMe)) { f(DropMe("world")).await; }