[Media] slopc: a proc macro that replaces todo!() with LLM-generated code at compile time. I am not sorry.

1995 points youpala 93 comments
[Media] slopc: a proc macro that replaces todo!() with LLM-generated code at compile time. I am not sorry.

tldr ; githoob/slopc

So. Recently, I watched "No Boilerplate"'s video on rust's macros and gave those a try after years of ignoring it: thinking it wouldn't help my productivity that much. nah uh ! felt like discovering your car has heated seat after 2 years on a lease. But then the intrusive thoughts came in: What if those heated seats were LLM driven, on fire, and the car is now driving itself into oncoming traffic ?

The voices in my head drove me to draft up some cursed proc-macro that would make my coworkers (me and my 2 cats) loose all the respect and faith they have for my technical skills.

#[slop] is an attempt to see how far I could push codegen and how flexible the rust compiler could be.. and it's limitations. This also made me realize that proc-macros could be a legitimate supply chain attack vector. But I'm not well versed on how one could mitigate this.


The boring stuff: #[slop] replaces todo!() with LLM-generated code at compile time using the comments, fn signature and project deps (with arguably a best-attempt at type discovery) as prompt context. Then feeds rustc errors back and retries until it compiles (or gives up).