get rid of futures

This commit is contained in:
nora 2025-10-17 23:00:46 +02:00
parent e9b6576d2b
commit 5ce26e9089
5 changed files with 62 additions and 103 deletions

91
Cargo.lock generated
View file

@ -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"

View file

@ -4,5 +4,4 @@ version = "0.1.0"
edition = "2024"
[dependencies]
futures-util = "0.3.31"
proc-macro-thing = { path = "proc-macro-thing" }

View file

@ -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**.
**Make sure to `export RUSTFLAGS=-Zincremental-verify-ich` first, otherwise it may not reproduce**.

View file

@ -1,10 +1,12 @@
#!/usr/bin/env bash
set -e
cargo clean -p reproduction
node toggle.js
cargo build
cargo build
node toggle.js

View file

@ -1,16 +1,63 @@
use futures_util::future::{Map, MapOk};
use std::pin::Pin;
struct MapOk2<Fut, F>(Fut, F);
impl<Fut, F> Future for MapOk2<Fut, F>
pub trait FnOnce1<A> {
type Output;
fn call_once(self, arg: A) -> Self::Output;
}
impl<T, A, R> FnOnce1<A> for T
where
Map<Fut, F>: Future,
T: FnOnce(A) -> R,
{
type Output = <Map<Fut, F> as Future>::Output;
type Output = R;
fn call_once(self, arg: A) -> R {
self(arg)
}
}
pub struct MapOkFn<F>(F);
impl<F, T, E> FnOnce1<Result<T, E>> for MapOkFn<F>
where
F: FnOnce1<T>,
{
type Output = Result<F::Output, E>;
fn call_once(self, arg: Result<T, E>) -> Self::Output {
arg.map(|x| self.0.call_once(x))
}
}
pub struct Map<Fut, F> {
inner: (Fut, F),
}
impl<Fut, F, T> Future for Map<Fut, F>
where
Fut: Future,
F: FnOnce1<Fut::Output, Output = T>,
{
type Output = T;
fn poll(
self: Pin<&mut Self>,
cx: &mut std::task::Context<'_>,
) -> std::task::Poll<Self::Output> {
self: core::pin::Pin<&mut Self>,
cx: &mut core::task::Context<'_>,
) -> core::task::Poll<Self::Output> {
loop {}
}
}
pub struct MapOk<Fut, F> {
inner: Map<Fut, MapOkFn<F>>,
}
impl<Fut, F> Future for MapOk<Fut, F>
where
Map<Fut, MapOkFn<F>>: Future,
{
type Output = <Map<Fut, MapOkFn<F>> as Future>::Output;
fn poll(
self: core::pin::Pin<&mut Self>,
cx: &mut core::task::Context<'_>,
) -> core::task::Poll<Self::Output> {
loop {}
}
}
@ -53,7 +100,6 @@ pub async fn bar_baz() {
}
// 1
// 2
#[derive(proc_macro_thing::MyMacro)]
#[helper]