Hi @oeble!
libcore
is usually not something that you remove; it's not really a "runtime" exactly. The important bit is definitions of bits of the language in Rust itself, which is why the issue talks about 'lang items'.
Is there a specific reason that you're looking to remove core, rather than "remove any runtime"? Rust with libcore is a bit conceptually lower in my mind than no libc
; removing libc
is closer to removing libstd
. That said, these distinctions, in some sense, are fairly arbitrary. It sounds to me like it's strictly about lessening the amount of code you'd need to have reviewed? It's roughtly 30 KLOC, so that's more than zero, but not that much. I can understand that every bit counts though! Most people that do embedded work still use libcore
, so while it can work, you'd be running into some interesting rough edges.
One thing you could do is, there are about ~70 "lang items", which are said implementations of stuff the language expects, in libcore. Copying just those out into a new package/straight into your code would be much smaller, for example, the first one is in cell.rs
:
#[lang = "unsafe_cell"]
#[stable(feature = "rust1", since = "1.0.0")]
pub struct UnsafeCell<T: ?Sized> {
value: T,
}
You'd remove the #[stable]
declaration, and you'd be good to go. You could only include the ones you actually use, and with no_core
, it will error on the ones that you use but don't have defined, so you could even only add them as you go. There's one related issue though; as this feature isn't stable, you'd be forced to pick a nightly build of the compiler. Doesn't mean you'd have to update at any particular frequency, of course, and due to Rust's development, nightly is fairly stable for this use-case, I'd think, as it's mostly higher-level stuff that'd be changing, or compiler internals you're not using. As I haven't done this myself, I can't truly advise on that, though.
Very excited about the idea of using Rust with trains!