I think C++ lambdas. Also, I believe Linus was talking about the inability of rust to handle out of memorys. It just Abort(). I'm I right? Not an expert on rust.
Conversation
Rust's high-level standard library has a choice between APIs using panic (unwinding or abort) or reporting an error.
The low-level subset of the standard library doesn't provide dynamic allocation. If you're using that, then you can choose to only provide APIs reporting errors.
1
The proof of concept kernel Rust implementation doesn't use the high-level standard library. They used the liballoc library as a placeholder and that comes with both forms of methods (panic and error reporting). They explained they'll only be providing error reporting variants.
1
Unlike C, Rust has standard support for using it as a freestanding language and with a low-level subset of the standard library.
The language fully supports implementing the allocation APIs via the kernel allocators and only providing the variants of those APIs not using panic.
1
1
It is annoying that you lose all the standard dynamically allocated collections, etc. and need to fork the libraries if you don't want method variants panicking on OOM.
So, for example, you'd want Vec::push(x) to return Option<T> or Result<T, E> to get back `x` on alloc failure.
1
1
As a language, it fully supports it. It fits well into the idiomatic error handling system based on sum types (typically Result) including syntactic sugar for bubbling up the errors.
Unlike C++, no-unwind support is standard, but high level stdlib mostly relies on panic on OOM.
1
The high level stdlib has no relevance to the kernel usage because it MUST use $![no_std] (freestanding) code. The high-level stdlib (libstd) uses lower-level standard libraries (libcore, liballoc, etc.) and they can use some of those, but they will need a stripped down liballoc.
1
So, basically, the only issue is they haven't yet forked liballoc to delete the methods doing panic on OOM. It's the same reason they need other placeholder stubs doing panic to fill in APIs used by stdlib code they've included via libcore, etc. Could fork libcore and delete it.
2
I don't know about the practicality of having to fork and maintain a likely incompatible version of rust, just for the Linux kernel.
2
They don't have to fork Rust. No language changes are required. The standard compiler works fine. They do need to implement allocation APIs, collections and the infrastructure for writing Linux kernel drivers. A lot of the point is making enforced safe APIs for those things.
1
They don't use the C standard library at all in the Linux kernel because it's ill suited to it and doesn't support freestanding use. They have to implement it themselves and make their own APIs.
They can use libcore for Rust, which they don't get with C. They can't use libstd.
Oh I see. It might even result in a better language, who panics on OOM anyway? its insane.
1
doc.rust-lang.org/alloc/ is the library they have to fork. They mostly need to delete the APIs using panic on OOM, rename the ones reporting errors to use the freed up simpler names and add some missing ones. It's not a very large task.
1
Show replies

