Project Details

☺️
Organization GNU Compiler Collection (GCC)
Project Title gccrs: Improving match expressions & pattern matching
Mentors Arthur Cohen, Pierre-Emmanuel Patry
Link to the repository https://github.com/Rust-GCC/gccrs

About

gccrs is an alternate compiler frontend for the Rust language that is built on top of GCC, with the goal of becoming fully upstream with the GNU toolchain. Compilation support for Rust patterns was not fully implemented previously, and this project aimed to bridge that gap in order to bring gccrs one step closer to the main goal of being able to compile code written for rustc 1.49.

Contributions to gccrs

Quick overview of all my PRs made to the gccrs repository. Below highlights the changes made during the project, together with the links of the pull requests involved.

Implemented compilation support for identifier pattern's subpatterns

#3811, #3814, #3822, #3828, #4072

Improved HIR dumps for patterns to make debugging easier

#3827

Fixed Internal Compiler Error (ICE) when generating code for match arms that contains tuple struct patterns

#3850

Implemented compilation support for tuple patterns containing rest patterns

#3859, #3863

Implemented compilation support for slice patterns containing rest patterns

#3887, #3913, #3981, #3998, #4017, #4039, #4062

Implemented compilation support for tuple struct patterns containing rest patterns

#4102

Follow-up task to be completed

The following task task has yet to be completed as of writing this, but may have been done by the time you read this.

let statements with most patterns are still not supported.

As of writing this, compilation for let statements for various patterns are unimplemented. For example, the code snipplet cannot be compiled with gccrs at the moment.

struct S {
    x: i32
}

fn main() {
    let a = S{x: 1};
    let S{x: b} = a;
}

Final notes

This is the biggest C++ codebase I have ever worked on, and completing this project gave me more experience in navigating C++ codebases, while also giving me a chance to hone my gdb debugging skills. Working on gccrs had let me better understand the benefits of applying visitor design patterns in a compiler, allowing better maintainability and easier addition of features.

I would like to give a huge shout-out to my mentors Arthur and Pierre-Emmanuel for giving me a chance to work on this project, and then for being awesome and approachable mentors! I would also like to give a shout-out to Philip Herron for being such a huge help and for reviewing most of my PRs :)