Virtual machine in Rust type system
⚓ Rust 📅 2026-03-03 👤 surdeus 👁️ 4Hello!
I wrote a virtual machine in the Rust type system! (Why not.)
This is a follow-up to a CTF challenge I wrote. It is a small proof-of-concept virtual machine embedded in the Rust type system, which uses trait resolution and in particular associated types to "execute" a program, represented as a type, to its final state. (The "execution" happens during Rust compilation.)
The VM architecture is simple: two 8-bit registers, a stack, a small number of instructions, including conditional control flow. However, other than patience and hitting the recursion limits, more useful/realistic architectures could be embedded as well.
I wrote a blog post that goes into more depth about how this was developed and how it all works: thenet / Virtual machine in Rust type resolution
The repository with all the (cleaned-up) code is here: GitHub - Aurel300/type-system-vm: VM in the Rust type system.
1 post - 1 participant
🏷️ Rust_feed