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.
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
Category | Last Month | This Month | Delta |
TODO | 55 | 53 | -2 |
In Progress | 3 | 3 | 0 |
Completed | 46 | 78 | +32 |
Test Cases
Category | Last Month | This Month | Delta |
Passing | 556 | 1008 | +452 |
Failed | 0 | 0 | – |
Bugs
Last Month | This Month | Delta | |
TODO | 3 | 6 | +3 |
In Progress | 0 | 1 | +1 |
Completed | 9 | 17 | +8 |
Milestones Progress
Milestones Progress | Last Month | This Month | Delta | Start Date | Completion Date | Target Date |
Data Structures 1 | 100% | 100% | – | 30th Nov 2020 | 27th Jan 2021 | 29th Jan 2021 |
Control Flow 1 | 33% | 100% | +67% | 28th Jan 2021 | 10th Feb 2021 | 26th Feb 2021 |
Data Structures 2 | 0% | 41% | +41% | 11th Feb 2021 | – | 28st May 2021 |
Data Structures 3 | 0% | 0% | – | – | – | 27th Aug 2021 |
Control Flow 2 | 0% | 0% | – | – | – | 29th Oct 2021 |
Imports and Visibility | 0% | 0% | – | – | – | TBD |
Risks
Risk | Impact (1-3) | Likelihood (0-10) | Risk (I * L) | Mitigation |
Copyright assignments | 2 | 5 | 10 | Be up front on all PRs that the code is destined to be upstreamed to FSF |
Planned Activities
- Generics on impl blocks and methods
- Type Resolution documentation
- Blog Post
- Shared logger project https://github.com/Rust-GCC/gccrs/issues/248
- Println and assert_eq macro interception