From 5ce26e90893eafd8b8fc767c5805be2239c81133 Mon Sep 17 00:00:00 2001 From: Noratrieb <48135649+Noratrieb@users.noreply.github.com> Date: Fri, 17 Oct 2025 23:00:46 +0200 Subject: [PATCH] get rid of futures --- Cargo.lock | 91 ----------------------------------------------------- Cargo.toml | 1 - README.md | 5 ++- repro.sh | 4 ++- src/main.rs | 64 +++++++++++++++++++++++++++++++------ 5 files changed, 62 insertions(+), 103 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5900d6f..dcd21f4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,104 +2,13 @@ # It is not intended for manual editing. version = 4 -[[package]] -name = "futures-core" -version = "0.3.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" - -[[package]] -name = "futures-macro" -version = "0.3.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "futures-task" -version = "0.3.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" - -[[package]] -name = "futures-util" -version = "0.3.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" -dependencies = [ - "futures-core", - "futures-macro", - "futures-task", - "pin-project-lite", - "pin-utils", - "slab", -] - -[[package]] -name = "pin-project-lite" -version = "0.2.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" - -[[package]] -name = "pin-utils" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" - [[package]] name = "proc-macro-thing" version = "0.1.0" -[[package]] -name = "proc-macro2" -version = "1.0.101" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89ae43fd86e4158d6db51ad8e2b80f313af9cc74f5c0e03ccb87de09998732de" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "quote" -version = "1.0.41" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce25767e7b499d1b604768e7cde645d14cc8584231ea6b295e9c9eb22c02e1d1" -dependencies = [ - "proc-macro2", -] - [[package]] name = "reproduction" version = "0.1.0" dependencies = [ - "futures-util", "proc-macro-thing", ] - -[[package]] -name = "slab" -version = "0.4.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a2ae44ef20feb57a68b23d846850f861394c2e02dc425a50098ae8c90267589" - -[[package]] -name = "syn" -version = "2.0.106" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ede7c438028d4436d71104916910f5bb611972c5cfd7f89b8300a8186e6fada6" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "unicode-ident" -version = "1.0.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f63a545481291138910575129486daeaf8ac54aee4387fe7906919f7830c7d9d" diff --git a/Cargo.toml b/Cargo.toml index fa610be..b589566 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,5 +4,4 @@ version = "0.1.0" edition = "2024" [dependencies] -futures-util = "0.3.31" proc-macro-thing = { path = "proc-macro-thing" } \ No newline at end of file diff --git a/README.md b/README.md index 76bff25..71d67fb 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # reproduction +https://github.com/rust-lang/rust/issues/147825 + To reproduce the issue, run `./repro.sh`. This will clean the build, and then toggle two lines between @@ -12,4 +14,5 @@ This will clean the build, and then toggle two lines between ``` which is enough to trigger the issue. -**Make sure to `export RUSTFLAGS=-Zincremental-verify-ich` first, otherwise it may not reproduce**. \ No newline at end of file +**Make sure to `export RUSTFLAGS=-Zincremental-verify-ich` first, otherwise it may not reproduce**. + diff --git a/repro.sh b/repro.sh index e772f0f..452e236 100755 --- a/repro.sh +++ b/repro.sh @@ -1,10 +1,12 @@ #!/usr/bin/env bash +set -e + cargo clean -p reproduction node toggle.js -cargo build +cargo build node toggle.js diff --git a/src/main.rs b/src/main.rs index 17c012a..21ef774 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,16 +1,63 @@ -use futures_util::future::{Map, MapOk}; use std::pin::Pin; -struct MapOk2(Fut, F); -impl Future for MapOk2 +pub trait FnOnce1 { + type Output; + fn call_once(self, arg: A) -> Self::Output; +} + +impl FnOnce1 for T where - Map: Future, + T: FnOnce(A) -> R, { - type Output = as Future>::Output; + type Output = R; + fn call_once(self, arg: A) -> R { + self(arg) + } +} + +pub struct MapOkFn(F); + +impl FnOnce1> for MapOkFn +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, +{ + type Output = T; fn poll( - self: Pin<&mut Self>, - cx: &mut std::task::Context<'_>, - ) -> std::task::Poll { + self: core::pin::Pin<&mut Self>, + cx: &mut core::task::Context<'_>, + ) -> core::task::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 {} } } @@ -53,7 +100,6 @@ pub async fn bar_baz() { } // 1 -// 2 #[derive(proc_macro_thing::MyMacro)] #[helper]