Back to browse
GitHub Repository

VM in the Rust type system.

7 starsRust

A virtual machine in the Rust type system

by Aurel300·Mar 3, 2026·2 points·0 comments

AI Analysis

●●●BangerWizardryBig BrainRabbit Hole

Rust type system executes a compile-time VM using trait resolution and associated types.

Strengths
  • Genuinely novel constraint: leverages Rust's next-gen solver to embed computation into type resolution itself.
  • Well-documented with blog post explaining the mechanics; clear architectural insight into how traits execute.
  • Transcends practical use case; pure demoscene-grade exploration of language capabilities.
Weaknesses
  • Explicitly a POC, not a tool: author warns against using in production; niche audience (type theorists).
  • Zero practical applications; exercises compiler but offers no utility beyond demonstrating language features.
Target Audience

Rust enthusiasts, type system researchers, competitive programmers

Post Description

As a follow-up to a CTF challenge I wrote, I created a small proof-of-concept virtual machine embedded in the Rust type system. Trait resolution and in particular associated types are used 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: https://www.thenet.sk/blog0011

Similar Projects

Developer Tools●●Solid

I've Added Gdbstub to UVM32

GDB stub on a 3KB embedded VM — debug bytecode on STM32 without leaving your workflow.

Niche GemWizardry
hamid_rostami
101mo ago