GCC Rust Weekly Status Report 6 – Generics WIP

In this weeks status report, multiple pieces of work are in progress. You can find on the repo a branch for adding generics to Algebraic data types. To implement Generics, two significant pieces of work are needed: a ParamTy, a placeholder TyTy to reference of Generic Argument, the other is a Substitution Mapping that allows usages of the template to substitute in the concrete type, which might be an Inference Variable.

Overview

As mentioned above, the generics work is still in progress; the focus is on getting this working for algebraic data types first, but with the implementation of this, the primitives the compiler will use is the ParamTy and Substitution mappings, and this needs to be reusable for all Generic Arguments.

So far, the branch can compile:

struct GenericStruct<T> {
    a: T,
    b: usize,
}

fn main() {
    let a1: GenericStruct<i8>;
    a1 = GenericStruct::<i8> { a: 1, b: 456 };

    let b1: i8 = a1.a;
    let c2: usize = a1.b;

    let a2;
    a2 = GenericStruct::<i32> { a: 123, b: 456 };

    let b2: i32 = a2.a;
    let c2: usize = a2.b;

    let a3;
    a3 = GenericStruct { a: 1.0, b: 456 };

    let b3: f32 = a3.a;
    let c3: usize = a3.b;
}

But there is no implementation of the substitution mappings, which means the management of the ParamTy won’t be reusable for Functions, for example. The branch is in the middle of clean up and adding in the Substitution mapper to make it more reusable.

We also need to thank a new contributor looking to join Rust for GSOC 2021 Yizhe who has submitted a much needed to refactor and cleanup of the base classes used in the TyTy module. I wish him all the best in his journey into compilers.

We also have now turned on a new GitHub action to verify the code formatting using clang-format in every PR thanks to Akshat Agarwal for this.

Completed Activities

  • Cleanup TyTy Base types and add is_equal method – PR238
  • Add clang format GitHub action – PR242 PR246
  • Remove unused code – PR244
  • Add debug interface to the GENERIC trees – PR245
  • WIP: Generics on branch – wip-generics

Overall Task Status

Last WeekThis WeekDelta
TODO4650+4
In Progress25+3
Completed7172+1
GitHub Issues

Test Cases

Last WeekThis WeekDelta
Passing812812
Failed00
make check-rust

Bugs

Last WeekThis WeekDelta
TODO55
In Progress00
Completed1717
GitHub bugs

Milestones Progress

MilestoneLast WeekThis WeekDeltaStart DateCompletion DateTarget
Data Structures 1100%100%30th November 202027th Jan 202129th Jan 2021
Control Flow 1100%100%28th Jan 202110th Feb 202126th Feb 2021
Data Structures 231%30%-1%11th Feb 202128st May 2021
Data Structures 30%0%27th Aug 2021
Control Flow 20%0%29th Oct 2021
Imports and Visibility0%0%TBD
GitHub Milestones

Risks

RiskImpact (1-3)Likelihood (0-10)Risk (I * L)Mitigation
Copyright assignments2510Be up front on all PRs that the code is destined to be upstreamed to FSF

Planned Activities

  • Finish cleanup of the first branch for generics
  • Add more tickets to milestone
  • Mutable borrows and double borrows

Leave a Reply

Your email address will not be published. Required fields are marked *