←back to thread

Eurydice: a Rust to C compiler

(jonathan.protzenko.fr)
187 points todsacerdoti | 1 comments | | HN request time: 0.199s | source
Show context
Surac ◴[] No.46181827[source]
I was always told rust uses llvm tokens not produceable by c code to do its magic. Was I informed wrong?
replies(2): >>46182005 #>>46182624 #
SAI_Peregrinus ◴[] No.46182624[source]
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.
replies(2): >>46182806 #>>46191253 #
1. 1718627440 ◴[] No.46191253[source]
C still has lifetime rules. It just has no syntax for them. What people are bitten with is that they violate the lifetime rules, but their compiler doesn't tell them.