A deeper look into the GCC Rust front-end
A deeper look into the GCC Rust front-end
Posted Oct 10, 2022 17:21 UTC (Mon) by josh (subscriber, #17465)In reply to: A deeper look into the GCC Rust front-end by tialaramex
Parent article: A deeper look into the GCC Rust front-end
I'd love to see that attribute stabilized. The last couple of times we've gotten hung up on all the *future* things we want to support there (e.g. alignment niches), but I think we should *just* support `#[niche(range = "...")]` and allow for the possibility of adding more in the future.
Posted Oct 10, 2022 19:36 UTC (Mon)
by tialaramex (subscriber, #21167)
[Link] (4 responses)
#[simple_niche=0x80]
That's enough to enable the Option-like niche optimisation guarantee, and thus turn all the cases where a C programmer would use a single sentinel value into type safe Rust. There are a lot of cases where saving a few bytes isn't actually important, choosing unstable to do this would be grossly disproportionate. But philosophically, the difference between "There's barely any overhead" and "The machine code is literally identical but thanks to Rust this is type safe" is huge.
Posted Oct 10, 2022 22:25 UTC (Mon)
by josh (subscriber, #17465)
[Link] (3 responses)
Posted Oct 11, 2022 0:38 UTC (Tue)
by NYKevin (subscriber, #129325)
[Link]
Posted Oct 11, 2022 8:16 UTC (Tue)
by farnz (subscriber, #17727)
[Link] (1 responses)
This feels like the "gotten hung up on all the *future* things we want to support there" comment you made earlier. A single valued niche is not stabilized, is definitely useful, is a subset of things that can reasonably be supported (indeed, it's a subset of things you can support today), and doesn't put as much of a long-term support burden on you as a range, or a more complex way to specify niches.
Perfect as enemy of good, and all that.
Posted Oct 11, 2022 9:37 UTC (Tue)
by josh (subscriber, #17465)
[Link]
A deeper look into the GCC Rust front-end
A deeper look into the GCC Rust front-end
A deeper look into the GCC Rust front-end
A deeper look into the GCC Rust front-end
A deeper look into the GCC Rust front-end