News for hackers. Stuff that matters.
Re:C2Rust: translate C into Rust code by csomar on Saturday June 23, 2018 @01:25PM (#17382273)
So the demo does actually translate C into unsafe Rust. I'm guessing this translator is, thus, unaware of Rust borrowing/ownership system?
Re:C2Rust: translate C into Rust code by glguy on Saturday June 23, 2018 @01:28PM (#17382292)
That's right. The translator just tries to preserve the original code. Refactoring things into proper, idiomatic Rust is the next step. The hope is that it will be easier to get the translation correct transforming unsafe Rust to safe Rust than having to go from C to safe Rust.
Re:C2Rust: translate C into Rust code by masklinn on Saturday June 23, 2018 @01:29PM (#17382294)
> So the demo does actually translate C into unsafe Rust.

It's semantics-preserving, and C constructs are not expected to match safe Rust, so that makes sense, Corrode does more or less the same.

Citrus generates "safe rust", it also doesn't generate working code.

Re:C2Rust: translate C into Rust code by sitkack on Saturday June 23, 2018 @02:19PM (#17382572)
The compilation target could be a Rust slab [0], much like Emscripten uses Typed Arrays [1]. In doing so, it would retain much of the safety properties of Rust, but it pushes the problem into maintaining "the heap" for the C code.

[0] https://github.com/carllerche/slab

[1] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Type...

Re:C2Rust: translate C into Rust code by masklinn on Saturday June 23, 2018 @04:13PM (#17383187)
That would be significantly less useful if the intent is to move the code from C to Rust.
Re:C2Rust: translate C into Rust code by sitkack on Saturday June 23, 2018 @06:11PM (#17383733)
How so?

It allows unsafe C to be incorporated into safe Rust while maintaining the same level of safety.

A similar less ergonomic solution would be to load C via WASM modules.

I'd take slab or wasm over whole lib translation into unsafe Rust.