Over the past week a lot of new Rust “gccrs” code was merged into the GCC 15 compiler code-base as a big step forward for this open-source Rust front-end. Another big batch of patches have been merged with for-loops now working among other functionality.
Arthur Cohen of Embecosm has merged what is planned to be the last batch of gccrs patches for synchronizing the gccrs development code with the upstream GCC Git state. Moving forward the patch churn will be hopefully smaller and on a weekly-ish basis.
With this latest batch of 100+ patches there are type system fixes, enhancements to their trait solver, and support for for-loops. Yes, the for loop support was a surprising challenge for gccrs to implement within the GNU Compiler Collection confines but is now working. There are also other code generation improvements and more.
Cohen commented yesterday on the GCC mailing list:
“Here is the last batch of our split patchset which aimed at synchronizing upstream with our development repo. Both repositories are now the same, with the latest patch pushed today corresponding to the latest pull-request merged this weekend on our side. Moving forward, I will be upstreaming these patchsets every Monday to keep the two repositories synchronized. Thank you again for taking the time to test our commits and review the code.
This series of commits focuses on type-system fixes and on the addition of multiple built-in derive macros, all required for compiling the `core` crate and the Rust code present in the Linux kernel. Our trait solver also got a lot better, with Philip Herron fixing a ton of issues in these last few weeks regarding complex code we encountered in `core`.
We can now also handle for-loops, which required a surprising amount of modifications to our AST, type-system and expansion passes. We have blogposts on our website detailing some of the complexity that went into for-loops, and why it took so long to get them in the compiler.
We have also improved our codegen for enums in order to more closely match the code generated by rustc, and have started adding handling for opaque types, another required feature for `core` and Rust-for-Linux.
Finally, we have added support for the question-mark operator, which also required multiple changes to our AST and type-system, and unveiled its share of interesting trait-solver bugs.
The next few weeks of work will focus on advancing our milestones in order to get as many features ready for 15.1, but most importantly we will focus on lowering the minimum required Rust version for our components to Rust 1.49. This will help in getting gccrs to compile on all the systems which attempt to, and will also make it possible for gccrs to compile its own dependencies once it becomes more mature.”
These latest Rust front-end improvements are in GCC Git ahead of the GCC 15 (GCC 15.1) stable release coming out in a few weeks.