Fix bugs in rust generator