5 ms·
But what about borrow checking? Will the transpiled code be runnable.
by billconan 5y ago
But what about borrow checking? Will the transpiled code be runnable.
- deleted 5y ago[deleted]
- qw3rty01 5y agoit doesn't convert pointers to references, it just uses pointers, so the borrow checker isn't invoked.
- TheMagicHorsey 5y agoFor the non-Rust programmers here, does that mean you don't get Rust's memory safety with this transpiler?
- deleted 5y ago[deleted]
- qw3rty01 5y agoCorrect, although it looks like converting some parts to safe code may be a future goal
- steveklabnik 5y agoWhat they've stated previously is that they plan to go with the approach of "compile C to unsafe Rust" and "compile unsafe Rust to safe Rust" as two separate things that could be chained together. I don't remember if it's meant to be literally another tool or just the general approach, but seems very interesting and sensible to me!
- necubi 5y agoThat's correct. There's no way to translate arbitrary C to memory safe code.
- jacquesm 5y agoIf you could, you wouldn't need Rust in the first place.
- TheMagicHorsey 5y agoThat's a good point. I feel stupid for asking now :D
- charcircuit 5y agoBut can we get 80% there and then have a human help out?
- pizza234 5y ago> But can we get 80% there and then have ma human help out? The problem is that for complex enough projects, the architectural redesign is considerably more demanding than a "remaining 20%". I can imagine it also being quite irritanting, due to shortcuts one may take in C taking advantage of implicit application logic (independently of them being warranted or not), that can't be directly translated due to the Rust strictness.
- pshc 5y agoI wonder if the brainiacs at OpenAI could train a neural net on human-written C -> Rust translations.
- amelius 5y agoBut what if the arbitrary C code was memory-safe to begin with?
- usrusr 5y agoFrom another non-rust programmer: all bugs you could write in C will still be there in the transpiled code and the parts that happen to not be bugs will still look as indistinguishable from bugs as they did before. Likely even more indistinguishable than before, because chances are you are better at reading idiomatic C than at reading the anti-idiomatic rust created by the transpiler. But there will likely be some low-hanging fruits of code that can subsequently be changed into idiomatic rust that simply cannot encode certain classes of bugs (without becoming as un-idiomatic as the transpiler output).
- accountofme 5y agoThe idea here is you get the c code transpiled verbatim into unsafe rust code. It is your job to then make it safe rust code :). Edit: spelling
- estebank 5y agoThe transpiled code will use pointers, it will not transform C-isms that could map to Rust-isms (like borrowing instead of pointers, or iterators instead of pointer arithmetic). This is meant to be only the first step in a Rust refactor. https://galois.com/blog/2018/08/c2rust/ https://galois.com/blog/2018/08/c2rust/ https://github.com/immunant/c2rust/wiki/Known-Limitations-of-Translation https://github.com/immunant/c2rust/wiki/Known-Limitations-of...