commit 93553d8aae0ac84c4c57517e6fbf3c40e310bc99 Author: Noratrieb <48135649+Noratrieb@users.noreply.github.com> Date: Fri Oct 17 22:21:28 2025 +0200 init diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..54466f5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/target + diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..2b73450 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "rust-analyzer.checkOnSave": false +} \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..5900d6f --- /dev/null +++ b/Cargo.lock @@ -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" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..fa610be --- /dev/null +++ b/Cargo.toml @@ -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" } \ No newline at end of file diff --git a/proc-macro-thing/.gitignore b/proc-macro-thing/.gitignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/proc-macro-thing/.gitignore @@ -0,0 +1 @@ +/target diff --git a/proc-macro-thing/Cargo.toml b/proc-macro-thing/Cargo.toml new file mode 100644 index 0000000..3c89579 --- /dev/null +++ b/proc-macro-thing/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name = "proc-macro-thing" +version = "0.1.0" +edition = "2024" + +[lib] +proc-macro = true \ No newline at end of file diff --git a/proc-macro-thing/src/lib.rs b/proc-macro-thing/src/lib.rs new file mode 100644 index 0000000..4f49080 --- /dev/null +++ b/proc-macro-thing/src/lib.rs @@ -0,0 +1,6 @@ +use proc_macro::TokenStream; + +#[proc_macro_derive(MyMacro, attributes(helper))] +pub fn hello(_: TokenStream) -> TokenStream { + "".parse().unwrap() +} \ No newline at end of file diff --git a/repro.sh b/repro.sh new file mode 100755 index 0000000..e772f0f --- /dev/null +++ b/repro.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +cargo clean -p reproduction + +node toggle.js + +cargo build + +node toggle.js + +cargo build diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..b970152 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,62 @@ +use futures_util::future::{Map, MapOk}; +use std::pin::Pin; + +struct MapOk2(Fut, F); +impl Future for MapOk2 +where + Map: Future, +{ + type Output = as Future>::Output; + fn poll( + self: Pin<&mut Self>, + cx: &mut std::task::Context<'_>, + ) -> std::task::Poll { + loop {} + } +} + +pub struct MaybeDone(Fut); + +pub fn take_output(x: Pin<&mut MaybeDone>) -> 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 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()))) + }); +} + +// 1 + // 2 + +#[derive(proc_macro_thing::MyMacro)] +#[helper] +pub struct Bazz {} + +fn main() {} diff --git a/toggle.js b/toggle.js new file mode 100644 index 0000000..bd68610 --- /dev/null +++ b/toggle.js @@ -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"));