Rust's compiler is based on the compiler framework LLVM. The compiler emits LLVM IR codes, which LLVM translates into an executable binary. All that typically happens transparently, but it's possible to read into the intermediate IR codes and also Assembler code if a programmer wants to dive deep.
Local variables are stored in the stack. These values have strictly limited lifetimes: values in the stack do not outlive their blocks. Values that are expected to live longer than their blocks are stored in the heap.
Rust is a safe language due to the lack of null pointers and due to the ownership, borrowing, and lifetimes memory handling system.
Regarding ownership, Rust values have either move or copy ...