This commit is contained in:
nora 2025-10-17 22:21:28 +02:00
commit 93553d8aae
10 changed files with 218 additions and 0 deletions

2
.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
/target

3
.vscode/settings.json vendored Normal file
View file

@ -0,0 +1,3 @@
{
"rust-analyzer.checkOnSave": false
}

105
Cargo.lock generated Normal file
View file

@ -0,0 +1,105 @@
# This file is automatically @generated by Cargo.
# 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"

8
Cargo.toml Normal file
View file

@ -0,0 +1,8 @@
[package]
name = "reproduction"
version = "0.1.0"
edition = "2024"
[dependencies]
futures-util = "0.3.31"
proc-macro-thing = { path = "proc-macro-thing" }

1
proc-macro-thing/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
/target

View file

@ -0,0 +1,7 @@
[package]
name = "proc-macro-thing"
version = "0.1.0"
edition = "2024"
[lib]
proc-macro = true

View file

@ -0,0 +1,6 @@
use proc_macro::TokenStream;
#[proc_macro_derive(MyMacro, attributes(helper))]
pub fn hello(_: TokenStream) -> TokenStream {
"".parse().unwrap()
}

11
repro.sh Executable file
View file

@ -0,0 +1,11 @@
#!/usr/bin/env bash
cargo clean -p reproduction
node toggle.js
cargo build
node toggle.js
cargo build

62
src/main.rs Normal file
View file

@ -0,0 +1,62 @@
use futures_util::future::{Map, MapOk};
use std::pin::Pin;
struct MapOk2<Fut, F>(Fut, F);
impl<Fut, F> Future for MapOk2<Fut, F>
where
Map<Fut, F>: Future,
{
type Output = <Map<Fut, F> as Future>::Output;
fn poll(
self: Pin<&mut Self>,
cx: &mut std::task::Context<'_>,
) -> std::task::Poll<Self::Output> {
loop {}
}
}
pub struct MaybeDone<Fut: Future>(Fut);
pub fn take_output<Fut: Future>(x: Pin<&mut MaybeDone<Fut>>) -> Fut::Output {
loop {}
}
struct AndThen<Fut1, F>(Fut1, F);
impl<Fut1, F> Future for AndThen<Fut1, F>
where
MapOk<Fut1, F>: Future,
{
type Output = ();
fn poll(
self: Pin<&mut Self>,
cx: &mut std::task::Context<'_>,
) -> std::task::Poll<Self::Output> {
loop {}
}
}
fn and_then<This, F>(s: This, f: F) -> AndThen<This, F> {
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())))
});
}
// 1
// 2
#[derive(proc_macro_thing::MyMacro)]
#[helper]
pub struct Bazz {}
fn main() {}

13
toggle.js Normal file
View file

@ -0,0 +1,13 @@
const fs = require("fs");
const c = fs.readFileSync("src/main.rs", "utf-8").split("\n");
const one = c.findIndex(l => l.includes("// 1"));
if (c[one + 1].includes("// 2")) {
c.splice(one + 1, 1);
} else {
c.splice(one + 1, 0, " // 2")
}
fs.writeFileSync("src/main.rs", c.join("\n"));