News for hackers. Stuff that matters.
Re:GCC 13 and the State of Gccrs by philberty on Tuesday April 25, 2023 @08:52AM (#35699768)
No core _is_ the Rust language, libcore is just a library which adds the "Rust abstractions" so you can actually write a for loop or create a slice or deref, add or anything else.

Libcore just gets compiled like any other rust crate just it does not have access to abstractions.

For example, you can still write C code without libc because C is a language libc is just a library libcore is pretty much the same. Though Rust makes alot of assumptions that libcore _should_ be there but its possible for it not to be.

Re:GCC 13 and the State of Gccrs by ChrisSD on Tuesday April 25, 2023 @08:57AM (#35699822)
core is part of the language (or at least, many parts of it are).

The way that rustc currently splits this up is an implementation detail of rustc, not something that must be copied exactly. Rust without core is not Rust. It's not even usable.

Re:GCC 13 and the State of Gccrs by jcranmer on Tuesday April 25, 2023 @10:48AM (#35701233)
> For example, you can still write C code without libc because C is a language libc is just a library libcore is pretty much the same. Though Rust makes alot of assumptions that libcore _should_ be there but its possible for it not to be.

The same core/std distinction exists in C. The headers float.h, iso646.h, limits.h, stdalign.h, stdarg.h, stdbit.h, stdbool.h, stddef.h, stdint.h, stdnoreturn.h, and parts of string.h, stdlib.h, fenv.h, and math.h are required to be supported in freestanding mode.

And, frankly, just about every language has this kind of core library/standard library distinction; at some point, parts of the compiler implementation of the language need to work with the library implementation details, and vice versa. Languages like Rust and C are somewhat unusual in actually identifying a subset of the standard library that is usable without a complete implementation of the standard library.

Re:GCC 13 and the State of Gccrs by tialaramex on Tuesday April 25, 2023 @12:17PM (#35702545)
You need to provide the langitems, it's true that core has a lot more than just the langitems, but the langitems are a lot and as somebody pointed to me on HN recently, they chase through into related stuff.

I was like, Option isn't special but, well, you do need to provide Some and None, and those are clearly two halves of an enum, so - that's Option is what that is.

You need Try, and unless you're going to write Try yourself to have some other behaviour that means you're writing ControlFlow and Result as well as Option.

I think that the work needed to make Ipv4Addr::is_documentation - a predicate which tells you whether the IPv4 Address you've got is, in fact, one reserved for documentation by the IETF RFC 5737 - is tiny compared to the struggle to get u32::is_power_of_two - a predicate which tells you if a 32-bit integer is a power of two - and so even though doubtless Rust doesn't care whether the former part of the core library works you might just as well.

Re:GCC 13 and the State of Gccrs by Thiez on Tuesday April 25, 2023 @12:57PM (#35703274)
A binary number is a power of two iff only a single bit is set, so pretty trivial to implement.
Re:GCC 13 and the State of Gccrs by tialaramex on Tuesday April 25, 2023 @01:13PM (#35703555)
Sure, it's literally self.count_ones() == 1 -- so we just implement count_ones() and ah, well, we could do all this by hand but turns out (fill in name of CPU) has a CPU instruction specifically for this. Rust calls the intrinsic we're about to go write intrinsics::ctpop()

Now we're writing per-ISA intrinsics, what was our goal again? Maybe I was too oblique, this stuff is all rabbit holes is what I was getting at. We're lucky these people even re-surface periodically with work and a blog post.

Re:GCC 13 and the State of Gccrs by barsonme on Friday April 28, 2023 @11:39PM (#35749803)
* * *