Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

You'd have to do a lot of flow analysis.

The first step would be to make everything const that can possibly be const. Const stuff can be borrowed non-mutably. Then make all variables have as narrow a scope as possible, even if this means putting in more bracketed blocks. Variables which are not initialized at declaration should be combined with their first assignment whenever possible.

Then you have to analyze what can have single ownership and what can't. Non-single-ownership data has to be refcounted. That makes the borrow checker happy, but may result in excessive refcounting if the analyzer can't track usage through complex code.

Pointers need to be analyzed for usage. If there's no pointer arithmetic, it can become a Rust reference, maybe with a "Some" if it can be nil. If there's pointer arithmetic, the pointer is going to have to be represented as a reference and a subscript.

You need a standard C library in Rust, with Rust safe equivalents of all the string functions.

It's a big job, but not impossible. It might be a marketable product.



Well, couldn't you then be making a safety-checking tool for C? If you can do that, it shouldn't be hard to translate from there to safe Rust.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: