From ee9a4559197aa2834e4dec6878b6a528a5d4c39e Mon Sep 17 00:00:00 2001 From: Noratrieb <48135649+Noratrieb@users.noreply.github.com> Date: Fri, 17 Oct 2025 23:08:04 +0200 Subject: [PATCH] integrate repro from cyrgani https://github.com/rust-lang/rust/issues/147825#issuecomment-3417158512 --- src/main.rs | 106 ++++++++++++---------------------------------------- 1 file changed, 24 insertions(+), 82 deletions(-) diff --git a/src/main.rs b/src/main.rs index 21ef774..628d1e7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,108 +1,50 @@ -use std::pin::Pin; +use std::{ + pin::Pin, + task::{Context, Poll}, +}; -pub trait FnOnce1 { +trait FnOnce1 { type Output; - fn call_once(self, arg: A) -> Self::Output; } -impl FnOnce1 for T +impl FnOnce1 for T where - T: FnOnce(A) -> R, + T: FnOnce() -> R, { type Output = R; - fn call_once(self, arg: A) -> R { - self(arg) - } } +struct Map(F); -pub struct MapOkFn(F); - -impl FnOnce1> for MapOkFn +impl Future for Map where - F: FnOnce1, -{ - type Output = Result; - fn call_once(self, arg: Result) -> Self::Output { - arg.map(|x| self.0.call_once(x)) - } -} - -pub struct Map { - inner: (Fut, F), -} - -impl Future for Map -where - Fut: Future, - F: FnOnce1, + F: FnOnce1, { type Output = T; - fn poll( - self: core::pin::Pin<&mut Self>, - cx: &mut core::task::Context<'_>, - ) -> core::task::Poll { + + fn poll(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll { loop {} } } -pub struct MapOk { - inner: Map>, -} - -impl Future for MapOk -where - Map>: Future, -{ - type Output = > as Future>::Output; - fn poll( - self: core::pin::Pin<&mut Self>, - cx: &mut core::task::Context<'_>, - ) -> core::task::Poll { - loop {} - } -} - -pub struct MaybeDone(Fut); - -pub fn take_output(x: Pin<&mut MaybeDone>) -> Fut::Output { +fn take_output(_: Pin<&mut Fut>) -> Fut::Output { loop {} } -struct AndThen(Fut1, F); -impl Future for AndThen -where - MapOk: Future, -{ - type Output = (); - fn poll( - self: Pin<&mut Self>, - cx: &mut std::task::Context<'_>, - ) -> std::task::Poll { - loop {} - } -} +fn main() { + let mut bazz = Map(async || ()); + let mut barr = async { Bazz {} }; -fn and_then(s: This, f: F) -> AndThen { - loop {} -} - -pub async fn bar_baz() { - let bazz = and_then(async { Ok::<(), ()>(()) }, async |_| Ok::<(), ()>(())); - let barr = async { Bazz {} }; - - let mut _fut0 = MaybeDone(bazz); - let mut _fut0 = unsafe { std::pin::Pin::new_unchecked(&mut _fut0) }; - let mut _fut1 = MaybeDone(barr); - let mut _fut1 = unsafe { std::pin::Pin::new_unchecked(&mut _fut1) }; - std::future::poll_fn(move |__cx: &mut std::task::Context<'_>| { - std::task::Poll::Ready((take_output(_fut0.as_mut()), take_output(_fut1.as_mut()))) - }); + let mut _fut0 = unsafe { Pin::new_unchecked(&mut bazz) }; + let mut _fut1 = unsafe { Pin::new_unchecked(&mut barr) }; + || { + take_output(_fut0.as_mut()); + take_output(_fut1.as_mut()); + }; } // 1 +// 2 #[derive(proc_macro_thing::MyMacro)] #[helper] -pub struct Bazz {} - -fn main() {} +struct Bazz {} \ No newline at end of file