3 ms·
> whichever_compiles!, a joke macro that takes multiple expressions, forks the compiler (as in a fork syscall), and compiles the first one that compiles to vali
by Tuna-Fish 5y ago
> whichever_compiles!, a joke macro that takes multiple expressions, forks the compiler (as in a fork syscall), and compiles the first one that compiles to valid rust.
This is inspired.
- iudqnolq 5y agoIt's definitely worth reading the full thread if you haven't > Did you know you can just fork() the @rustlang compiler from your proc_macro? :D > This is, of course, a horrible idea. > Unfortunately rustc is multithreaded and fork() only forks one thread. We'll just assume the other threads weren't doing anything important. > In today's rustc, this means we're only missing the main thread in the fork. But that one was only going to call exit() after joining our thread anyway, so not very important. It just means the process always exits with a success status. So instead we grep the output for "error". Any my favorite reply: > Is this a rust implementation of autoconf? https://mobile.twitter.com/m_ou_se/status/1368632701448818691 https://mobile.twitter.com/m_ou_se/status/136863270144881869...