struct vec_int vec = VEC_INT_EMPTY;
vec_int_push(&vec,1);
vec_int_push(&vec,2);
vec_int_push(&vec,3);
even in C. They're talking about things like: Foo foo; // Foo::Foo allocates
z = x + y; // operator+ allocates
w = x; // operator= allocates
foo += *bar; // operator* allocates
Rust can do most of those things, but it's not encouraged and significantly less pervasive, especially in the kind of code you'd want to use in a kernel in the first place.Sure in theory. But in practice most consider such a behavior a code small or straight bug an d fix it.
So there is a difference in practice.
You can also use asm blocks (or string literals casted to function pointers) to wreak all kinds of havok. Oddly, noone seems particularly concerned about that.
The only way to have explicit allocations in Rust is to not use libstd (but this isn't special in the context of writing OSes anyway) and disallow using the GlobalAlloc trait, as well as any third-party libraries that rely on it. Unfortunately both the explicit allocator LocalAlloc and the global allocator GlobalAlloc, as well as all the types that rely on GlobalAlloc, are defined in the same library liballoc, so keeping one and removing the others requires patching liballoc.
As far as other non-C languages go, Zig has an explicit allocator that neeeds to be threaded through any function that wants to allocate, which would likely satisfy Linus's requirement.
Then again, I don't commonly use any of the languages in question, so maybe I'm missing the point entirely.
gotta explain what's the difference between
and