GCC Rust Monthly Report #3 Feb 2021

For this year, my goal is to get through generics and traits. For me, this is where the biggest unknowns lie for the compiler. With the early completion date of completion of the Control Flow 1 milestone, not only will this help estimate timelines more accurately, but it has also enabled me to get a head start on generics.

Rust Bash – Talk by myself on the compiler

Please find a folder of example demo applications for this Monthly Report. https://github.com/Rust-GCC/Reporting/tree/main/Feb-2021/monthly-demo

Overview

With the completion of Control flow 1, we can now compile Loop Expressions which are infinite loops, as well as WhileLoopExpr expressions. In doing this, we needed to implement Break and continue expressions. The interesting part here is that you can actually break from loops with a value or a label in rust.

fn main() {   
    let mut a = 1;
    let mut b = 1;
                                                             
    // first number in Fibonacci sequence over 10:
    let fib = loop {
        if b > 10 {                     
            break b;           
        }
        let c = a + b; 
        a = b;
        b = c;                                   
    };                                           
}          

On the front of Rust’s generics, we can now compile the following generics example; note this code also works for TupleStructs, and under the hood, these are Algebraic data types.

struct Foo {                                   
    a: f32,                                    
    b: bool,                                   
}                                              

struct GenericStruct<T> {
    a: T,
    b: usize,                                    
}                                                
                                                             
fn main() {                                      
    let a1;                                      
    a1 = Foo { a: 1.0, b: false };
                                                             
    let b1: f32 = a1.a;
    let c1: bool = a1.b;                                                                                                   
                                                                                                                           
    let a2: GenericStruct<i8>;                                                                                             
    a2 = GenericStruct::<i8> { a: 1, b: 456 };                                                                             
                                                                                                                           
    let b2: i8 = a2.a;                                                                                                     
    let c2: usize = a2.b;                                                                                                  
                                                                                                                           
    let a3;
    a3 = GenericStruct::<i32> { a: 123, b: 456 };

    let b3: i32 = a3.a;                                                                                                                                                                                                                                
    let c3: usize = a3.b;                                                                                                                                                                                                                              
                                                                                                                                                                                                                                                       
    let a4;
    a4 = GenericStruct { a: 1.0, b: 456 };

    let b4: f32 = a4.a;              
    let c4: usize = a4.b;
                                                             
    let a5;                                                
    a5 = GenericStruct::<_> { a: true, b: 456 };

    let b5: bool = a5.a;
    let c5: usize = a5.b;
}

Moving forward on generics, this will be extended for impl blocks, functions and methods.

Completed Activities

  • LoopExpr
  • WhileLoopExpr
  • ContinueExpr
  • BreakExpr
  • Char Type
  • Str Literals
  • Generics on Algebraic data types
  • Fix |= parser bug
  • Fix function pointer inside struct bug
  • Fix let a = if {} else {} bug

Overall Task Status

CategoryLast MonthThis MonthDelta
TODO5553-2
In Progress330
Completed4678+32
GitHub Issues

Test Cases

CategoryLast MonthThis MonthDelta
Passing5561008+452
Failed00
make check-rust

Bugs

Last MonthThis MonthDelta
TODO36+3
In Progress01+1
Completed917+8
GitHub bugs

Milestones Progress

Milestones ProgressLast MonthThis MonthDeltaStart DateCompletion DateTarget Date
Data Structures 1100%100%30th Nov 202027th Jan 202129th Jan 2021
Control Flow 133%100%+67%28th Jan 202110th Feb 202126th Feb 2021
Data Structures 20%41%+41%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

Leave a Reply

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