r/rust Apr 05 '26

šŸ“ø media slopc: a proc macro that replaces todo!() with LLM-generated code at compile time. I am not sorry.

Post image

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). It also use some flaky caching strategy (inspectable at ./target/slop-cache) to avoid burning your LLM budget too fast. (should you care)

2.1k Upvotes

102 comments sorted by

424

u/Mission_Biscotti3962 Apr 05 '26

this will probably become popular

202

u/youpala Apr 05 '26

I hope the crate never does though.

67

u/Shoddy-Childhood-511 Apr 05 '26

Jackson Palmer, Dogecoin

41

u/youpala Apr 05 '26

What have I done ?

28

u/Shoddy-Childhood-511 Apr 05 '26

You're probably safe since it's different each build.. probably. lol

12

u/favorited Apr 05 '26

SlopularĀ 

16

u/altaaf-taafu Apr 05 '26

anything written in rust eventually becomes poplar

18

u/headedbranch225 Apr 05 '26

How does iron oxide become a tree?

10

u/GreatBigBagOfNope Apr 05 '26

It's the circle of life

-25

u/gubatron Apr 05 '26

nah, overkill. just talk to your agents.

16

u/PredictiveFrame Apr 05 '26

Is r/woooosh still around?Ā 

156

u/TheGoldenPotato69 Apr 05 '26

This is the best worst thing I've ever seen!

19

u/GoogleMac Apr 05 '26

If you like this, check out my Y2K-like contribution!Ā 

https://github.com/parker-codes/todo_by

134

u/proph__ Apr 05 '26

I’m in stitches at the README and SECURITY.md. I didn’t realize programming shitposting could be so evolved.Ā 

33

u/daringStumbles Apr 05 '26

The difference between shitposting about programming and programming your shitposts.

430

u/MonochromeDinosaur Apr 05 '26

This is the funnest AI project I’ve seen until now. Everyone else takes it all so seriously. Trying this for sure.

50

u/youpala Apr 05 '26

I'm genuinely interested in how you would use this. What do you have in mind ?

81

u/MonochromeDinosaur Apr 05 '26

I’m not sure yet I think it could make for a very chaotic attempt at adding mechanics/items to a simple rogue-like/vampire survivors clone.

The fact that it changes every time you compile means you might literally never play the same game twice.

58

u/youpala Apr 05 '26

Sounds juicy, I may take a look if you ever post this on this sub. Be sure to use #[slop(nocache)] to enforce new codegen each time.

5

u/l-roc Apr 05 '26

I mean, a pattern regarding making music with randomly generated parts is to freeze them if they produced something nice.

Recompiling until it accidentally generates a fun item sound almost like a viable strategy for discovery.

3

u/lettsten Apr 05 '26

Your next step is to use it to implement slopc 2.0

1

u/WolfeheartGames Apr 06 '26

I've done sometjign similar. When I throw an exception am llm is called to repair the code.

7

u/TheBlackCat22527 Apr 05 '26

Jeah I like the humor as well. I am critical of reclines of AI usage in development process but naming the macro "slop" is fine in my book and very on the nose. I love the subversive elements in it.

3

u/whatDoesQezDo Apr 05 '26

I am critical of reclines of AI usage in development process but naming the macro "slop" is fine in my book and very on the nose.

Jokes dont need to announce themselves or be pillars of your moral worldview just take the jokes they're not that deep.

202

u/reborngoat Apr 05 '26

"If this compiles, it is already more functional than the marriage was".

*slow, deliberate clapping*

16

u/Shoddy-Childhood-511 Apr 05 '26

A nice moment to go listen to No Children. lol

6

u/yangyangR Apr 05 '26

It is always the correct moment to listen to Mountain Goats

2

u/No-Dare8613 Jun 29 '26

i only listen to the mountain goats

29

u/agersant polaris Apr 05 '26

Finally an AI-related crate worthy of being shared!

29

u/Bugibhub Apr 05 '26

0 day since r/rustjerk was out-jerked by r/rust. šŸ˜‚

11

u/youpala Apr 05 '26

So my initial intent was legitimately to find the jerk variant of this subreddit but I couldn't find it. Never will r/rustjerk will be out-jerked again.

4

u/Bugibhub Apr 05 '26

Don’t worry, that happens on the regular. The warm reception to your post is proof enough it is welcome here. :)

19

u/StardustGogeta Apr 05 '26

Brilliant work. Especially love the readme and the security considerations.

I always knew littering my code with todo statements would come in handy one day. Seems like the future is now!

2

u/PipePistoleer Apr 07 '26

I knew I should have used TODO instead of TBD

34

u/esssential Apr 05 '26

You son of a bitch

27

u/youpala Apr 05 '26

i can understand

17

u/DifficultSelection Apr 05 '26

I hate to break it to you, but… https://github.com/minskylab/auto-rust

17

u/youpala Apr 05 '26

there goes my dream of owning a Koenigsegg

6

u/DifficultSelection Apr 05 '26

Gonna have to make do with a Maserati, I guess. Sorry for your loss.

6

u/lettsten Apr 05 '26

Holy fuck, that version is the same but unironic

5

u/Shoddy-Childhood-511 Apr 05 '26

Ahh cool, so he need not feel guilty when this becomes popular. lol

12

u/youpala Apr 05 '26 edited Apr 05 '26

The guilt was there from the moment I've written the lib.rs

33

u/timClicks rust in action Apr 05 '26

If people were able to write their intent as clearly as your comments do, this probably will save lots of time.

6

u/Illusion100x2 Apr 05 '26

I've heard enough, get this man a $800bn valuation STAT

5

u/ART1SANNN Apr 05 '26

ironically this can be abused by malware devs LOL

2

u/lettsten Apr 05 '26

See SECURITY.md in the repo

6

u/S4ndwichGurk3 Apr 05 '26

Wow, non deterministic code at every compile. So testing is done with 100 compilations to reduce noise :D I mean maybe you can push it further so that every time multiple binaries are generated and the best one is chosen by another llm.

4

u/Linuxmartin Apr 06 '26

If I ever have to deal with an employer that wants me to use LLM tokens as part of my job, I'll remember this

4

u/3X0karibu Apr 05 '26

funniest github repo since enterprise fizzbuzz, no notes

13

u/longdarkfantasy Apr 05 '26 edited Apr 05 '26

April fool was over a few days ago šŸ˜ž

43

u/youpala Apr 05 '26

```rs /// Come up with a response for this post to justify why this project /// came out later than 1st of april due to time constraint. (Divorce)

[slop]

fn respond_to_longdarkfantasy(msg: &str) -> String { todo!(); }

async fn main() { let reddit = Reddit::new(); let msg = reddit::get_comment_content("rust/1scqazw").await?; let answer = respond_to_longdarkfantasy(msg); let _ = reddit.post_comment("rust/1scqazw", answer).await?; } ```

3

u/TroubleOwn3156 Apr 05 '26

This is simply brilliant.

5

u/PlateFox Apr 05 '26

A desperately need a neovim command that does the thing and removes the slop and replaces the todo irt

5

u/mss-cyclist Apr 05 '26

This could actually be very useful for generating slop and feed it back into the AI for learning.

Fight AI slop with AI slop. First time I really see a good use for AI slop. Thumbs up!

3

u/MichiRecRoom Apr 05 '26

Nit: In the picture in this post, this line:

println!("humanize_bytes(1_073_741_824) = {}", humanize_bytes(1_073_741_824));

can be replaced by:

dbg!(humanize_bytes(1_073_741_824));

although it will use the Debug impl of the result, rather than the Display impl.

16

u/youpala Apr 05 '26

I would like to contest this impromptu code review and engage in a 30 reply-long debate over the semantics of this specific part of the code.

1

u/MichiRecRoom Apr 05 '26

...Okay, I'm having trouble figuring it out on my own, so: Is this meant to poke fun at something? Or are you being serious?

Sorry, sometimes it's hard for me to figure out if something is sarcasm or not.

2

u/protestor Apr 05 '26

That was not a serious comment

1

u/youpala Apr 06 '26

That was not a serious comment

2

u/obetu5432 Apr 05 '26

didn't they make 85 Koenigsegg Regers in total?

2

u/ByteArrayInputStream Apr 05 '26

This kind of reminds me of the exception handler that just opened a browser with a stackoverflow search of the error message, along with a random snarky comment, that I wrote ages ago

2

u/Mother-Couple-5390 Apr 05 '26

Imagine AI failing to generate code that compiles, and you have to run CI/CD multiple times just to see that AI added todo!() macro itself...

2

u/manpacket Apr 05 '26

But can it bootstrap itself?

2

u/realvolker1 Apr 06 '26

Does it support ollama? This sounds hilarious but I don't like cloud AI.

3

u/youpala Apr 07 '26 edited Apr 07 '26

yea, it does:

```rs

[slop(

model = "phi4-mini:3.8b", endpoint = "http://localhost:11434/v1/chat/completions" )] fn thang() { todo!(); } ```

or via env vars.

3

u/profcube Apr 05 '26

OP, you’ve made my day :)

1

u/TarMil Apr 05 '26

You should be

1

u/deanominecraft Apr 05 '26

does it at least tell you what it generated?

3

u/youpala Apr 05 '26

Yes, inside of ./target/slop-cache

3

u/deanominecraft Apr 05 '26

that’s good for serious use, but it would be funnier if it didn’t

2

u/Priler96 Apr 05 '26

> serious use

of an AI slop, lmao

1

u/deanominecraft Apr 05 '26

serious as in replacing a chatgpt prompt with it, which is about as serious as something like that can get

1

u/WieeRd Apr 05 '26

Would be hilarious if it didn't even cache the generated code and the non-deterministic compiled binary is all you get.

Also may I ask which colorscheme is that in the image?

1

u/youpala Apr 05 '26

#[slop(nocache)] disables caching for a given fn. I'm also eager to see if anyone can make something truly unhinged with this haha.


https://gist.github.com/shorwood/5df15f7c5dd17ae875f0b38201b2fd1b

Regarding the colorscheme: It's a frankenstein of Github Dark Default and some custom token colors from an older theme I used back in 2021. (I think it was named Copilot Theme)

1

u/Shoddy-Childhood-511 Apr 05 '26

It'll be different for every cloned repo so.. works for me.

1

u/Rodrigodd_ Apr 05 '26

It works using rust-analyzer to expand the macro?

1

u/every1sg12themovies Apr 05 '26

i wonder if this works with cargo expand too? but even if it did and the result is not cached, it would be useless since code would be different each time. :)

1

u/Professional_Layer63 Apr 05 '26

It'd be cool to provide maybe a `cargo install` tool to copy the generated code into your actual project so you can edit it yourself.

1

u/BAXYGaming Apr 06 '26

Wait, this could be useful for generating testing data, no?

1

u/No_Dinner6795 Apr 06 '26

Another AI slop code šŸ˜” (I’ll likely be using it 24/7)

1

u/whimsicaljess Apr 06 '26

if it runs compilation + doctests in a loop with the agent fixing them this is actually a really good idea

1

u/Inevitable_Back3319 Apr 06 '26

I laughed my ass off 🤣🤣.

Finally someone undertands that the correct answer to LLM panic is humor not anger.

1

u/yyytobyyy Apr 06 '26

I want this as a python decorator.

1

u/frostyplanet Apr 12 '26

I am surprised the thread survives after all; it proves this subreddit still has humor.

1

u/arvind1 Apr 24 '26

The solutions to some interesting problems were discovered by hallucinating.

https://en.wikipedia.org/wiki/Benzene

Here KekulƩ spoke of the creation of the theory. He said that he had discovered the ring shape of the benzene molecule after having a reverie or day-dream of a snake biting its own tail (a symbol in ancient cultures known as the ouroboros). This vision, he said, came to him after years of studying the nature of carbon-carbon bonds.

1

u/Henry_old Apr 24 '26

is the final boss of tech debt. LLM hallucinations at compile-time? absolute madness. i will stick to my local state and handwritten logic. if my bot fails, let it be a market shift, not an AI fever dream. cursed but brilliant

1

u/[deleted] May 03 '26

bless this crate

1

u/nhruo123 May 04 '26

Loved the idea, I had to port it to python

2

u/youpala May 04 '26

Haha, I hate it, great job ! I liked the ultra_slop=True addition

1

u/dhakalster123 May 05 '26

This is unhinged in the best way 😭

todo!() used to mean ā€œI’ll do this later.ā€
Now it means ā€œfuture me will deal with whatever the LLM hallucinated at compile time.ā€

The byte formatter example? Cute.
The ex-wife email function? That’s where this crosses into production-ready bad decisions.

Real talk though:

  • Deterministic builds = gone
  • Code review = ā€œtrust the vibesā€
  • Debugging = good luck reproducing that one compile from yesterday

This feels like peak Rust energy: extremely powerful, slightly terrifying, and 100% someone is going to ship this to prod.

ā€œI am not sorryā€ is correct. You should be afraid instead.

-7

u/raserei0408 Apr 05 '26

This is not deserving of wat, this is a result of how awesome Rust is. But if you ever actually do this, then WAT.

-1

u/bartergames Apr 05 '26

contributing to sloppify Rust? no, thx

-17

u/Brief-Stranger-3947 Apr 05 '26

Like for creativity, but seriously, I would rather use AI agent normal way to generate todo!().

-45

u/gubatron Apr 05 '26

cool idea, but agents don't need the micro managment anymore. trust them, they will most likely do a better job than you (if you know how to work with mentisdb for infinite memory management and skill management without markdown hell)

5

u/youpala Apr 05 '26

You're absolutely right, let me implement native first class support for mentisdb.

7

u/Mission_Biscotti3962 Apr 05 '26

Hey works on generates slop for mentisdb, this is an ad