Control flow 1 Milestone as been completed this means the front-end can now handle Block expressions, Loop and While Loop expressions, as well as method resolution. The remaining “For” loop construct has been left out for now. This requires Iterators that will need generics and traits to be implemented first.
Since the milestone has been completed earlier than the target date, this will help shape the future estimates. Generics and Traits are complex in rust and 3 months each have been allocated to these features for now, but this might change as time goes by next month. Note that the Data Structures 2 project is not fully fleshed out with tickets so the percentage of completion is not accurate at the moment.
There is now a student interested in Google Summer of Code 2021 to work on GCC Rust, which I will mentor to get involved.
Overview of merges
Since last week the IfExpr parser bug ( https://github.com/Rust-GCC/gccrs/issues/214) has been fixed allowing for the syntax below to be compilable.
fn main() {
let a = 123;
let b = if a > 10 { a - 1 } else { a + 1 };
}
The bug fix ( https://github.com/Rust-GCC/gccrs/issues/173 ) for allowing the final compound assignment operator of |= has been merged.
Loop expressions are infinite loops, but if you use the break expression with a value, this acts as an implicit return for this type of Loop Expression, the value becomes assignable.
fn main() {
let mut a = 1;
let mut b = 1;
let val = loop {
if b > 10 {
break b;
}
let c = a + b;
a = b;
b = c;
};
}
The other usage of a Break Expression is where you use labels. This allows for a break to goto a label, in this case, the beginning of a loop expression.
fn main() {
'outer: loop {
'inner: loop {
break 'outer;
}
}
}
It is worth noting that While Loops have also been implemented but while loops do not allow for breaks to return a value and return:
error[E0571]: `break` with value from a `while` loop
--> test.rs:5:9
|
5 | break 123;
| ^^^^^^^^^ can only break with a value inside `loop` or breakable block
If you consider an infinite loop expression, the only way for this type of loop to exit is to use a break expression that can be regarded as a return expression.
On the other hand, loops have a predicate expression that is evaluated to determine whether it will loop again or not. This means it might exit on its own, which can leave an opportunity for no final value to type resolve.
The final piece that was merged was BorrowExpressions and DereferenceExpressions which can be considered similar to the C++ references but the mutable borrow has not implemented yet.
Merged PRs
- Fix bug parsing rust Ternary Expressions – PR216
- Fix bug handling Function Pointer CallExpr as a FieldAccessExpr – let a = (d.a)(d.b); – PR218
- Fix bug parsing |= compound assignment – PR221
- Add compilation option -frust-dump-all – PR222
- LoopExpr WhileLoopExpr, ContinueExpr and BreakExpr – PR223 PR229
- BorrowExpr and DereferenceExpr – PR231
- Char Type – PR230
- Changes into the AST to reuse the parser and prepare for macro expansion – PR227
Overall Task Status
Last Week | This Week | Delta | |
TODO | 53 | 46 | -7 |
In Progress | 4 | 2 | -2 |
Completed | 54 | 71 | +17 |
Test Cases
Last Week | This Week | Delta | |
Passing | 688 | 812 | +124 |
Failed | 0 | 0 | 0 |
Bugs
Last Week | This Week | Delta | |
TODO | 4 | 5 | +1 |
In Progress | 2 | 0 | -2 |
Completed | 10 | 17 | +7 |
Milestones Progress
Milestone | Last Week | This Week | Delta | Start Date | Completion Date | Target |
Data Structures 1 | 100% | 100% | – | 30th Nov 2020 | 27th Jan 2021 | 29th Jan 2021 |
Control Flow 1 | 68% | 100% | +32% | 28th Jan 2021 | 10th Feb 2021 | 26th Feb 2021 |
Data Structures 2 | 0% | 31% | +31% | 11th Feb 20 | – | 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
- Documentation
- Ticket planning for Generics
- Investigate how other GCC/LLVM front-ends implement Templates
- Mutable Borrowing
- Add in adjustments for method receivers to borrow self for example