logoalt Hacker News

Suracyesterday at 2:16 PM2 repliesview on HN

I was always told rust uses llvm tokens not produceable by c code to do its magic. Was I informed wrong?


Replies

SAI_Peregrinusyesterday at 3:58 PM

You probably misunderstood. C can represent any program's semantics, since it's Turing-complete (modulo finite memory). C can't encode the lifetimes Rust uses, but those get erased during compilation to MIR. This takes MIR from rustc (where borrow checking has been completed and lifetime annotations erased) and outputs C with the same semantics. LLVM doesn't use tokens not produceable by C, but rustc does.

show 1 reply
mmastracyesterday at 2:43 PM

There are multiple stages of IR in the compiler, basically