Thanks again to Open Source Security, inc and Embecosm for their ongoing support for this project.
Milestone Progress
This week I made good progress in adding Type Coercion code for the first coercion site of assignment expressions, this allows us to implement RawPointers and unsafe. The other major piece of work has been TypeCasts which are almost like coercions but they are distinct such that casts can change any number type regardless of truncation and pointers and references can ignore mutability. The TypeCast work has coincided with the fantastic Mark Wielaard fixing issues in the parser to support unsafe and casts. The TypeCasts and TypeBounds work has been an ongoing task thought traits and this week I aim to get these merged now.
In other news the Rustc compiler is now close to stabilizing GAT’s (Generic Associated Types) this is something I did not factor into my Traits milestone but ideally, it would be best to tackle this now instead of later. So I will need to spend some time to look at what is missing in gccrs and try to estimate how difficult this piece of work will be which will change the timeline.
Google Summer of Code
Cargo Support
Arthur Cohen has two remaining issues to fix before the Google summer of code project will be complete, which are about decoupling the data structures and code. This will allow him to move on, to get more experience with the compiler proper.
Static Analysis
Wenzhang Yang since he has completed the goals of his GSoC and the other features are blocked since gccrs has not implemented pattern matching yet we have scoped out more work and this needed time to research the best approach to fix our unused variables scan.
Detailed changelog
Raw Pointers and Coercions
In rust, you cannot implement pointers until you have implemented type coercions. For example:
pub fn main() {
let mut num = 2;
let a: *const i32 = #
}
The borrow expression of num signifies a Reference (int&) but to get a pointer we need to explicitly say we want ‘a’ to be a pointer and the assignment statement is not an assignment it is a coercion-site this allows the compiler to make coercion of (int&) into (const int*). Coercion sites allow moving from mutable references to const references but not the other way round. This is explicitly different to TypeCasts using ‘as’ keyword which allows you to ignore mutability.
Initial support for unsafe
We now support compiling unsafe blocks such as:
pub fn main() {
let mut num = 2;
let r1: *const i32 = #
let r2 = unsafe { *r1 } + unsafe { *r1 };
let r3 = num;
num = 4;
let r4 = num + unsafe { *r1 } * r3;
let _eightteen = r2 + r3 + r4;
}
Currently, this fixes the ICE we had and does not implement the rules for error checking that raw pointer dereferences must be inside unsafe this will come later on.
Completed Activities
- Assignments are a type of coercion site PR577
- Add lowering and typechecking for unsafe blocks PR582 PR587
- Raw pointers PR579 PR589
- Support byte string literals PR594
- Fix bug parsing unsafe in expressions PR591
- Fix parser bug in ranges PR593
- Fix parser bug in unions PR590
- Cleanup PR578 PR585 PR586
Contributors this Week
Overall Task Status
Category | Last Week | This Week | Delta |
TODO | 87 | 86 | -1 |
In Progress | 8 | 9 | +1 |
Completed | 166 | 173 | +7 |
Test Cases
Category | Last Week | This Week | Delta |
Passing | 3402 | 3529 | +127 |
XFAIL | 15 | 14 | -1 |
Bugs
Category | Last Week | This Week | Delta |
TODO | 20 | 19 | -1 |
In Progress | 3 | 3 | – |
Completed | 53 | 58 | +5 |
Milestones Progress
Milestone | Last Week | This Week | Delta | Start Date | Completion Date | Target |
Data Structures 1 – Core | 100% | 100% | – | 30th Nov 2020 | 27th Jan 2021 | 29th Jan 2021 |
Control Flow 1 – Core | 100% | 100% | – | 28th Jan 2021 | 10th Feb 2021 | 26th Feb 2021 |
Data Structures 2 – Generics | 100% | 100% | – | 11th Feb 2021 | 14th May 2021 | 28th May 2021 |
Data Structures 3 – Traits | 54% | 64% | +10% | 20th May 2021 | – | 27th Aug 2021 |
Control Flow 2 – Pattern Matching | 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 | 2 | 4 | Be up front on all PRs that the code is destined to be upstreamed to FSF |
Rust Language Changes | 3 | 7 | 21 | Keep up to date with the Rust language on a regular basis |
Planned Activities
- Finish TypeCastExpr work
- Finish cleanup of typebounds branch with super traits