GCC Rust Weekly Status Report 23

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

Contributors this Week

Overall Task Status

CategoryLast WeekThis WeekDelta
In Progress89+1
Completed 166173+7
GitHub Issues

Test Cases

CategoryLast WeekThis WeekDelta
make check-rust


CategoryLast WeekThis WeekDelta
In Progress33
GitHub Bugs

Milestones Progress

MilestoneLast WeekThis WeekDeltaStart DateCompletion DateTarget
Data Structures 1 – Core100%100%30th Nov 202027th Jan 202129th Jan 2021
Control Flow 1 – Core100%100%28th Jan 202110th Feb 202126th Feb 2021
Data Structures 2 – Generics100%100%11th Feb 202114th May 202128th May 2021
Data Structures 3 – Traits54%64%+10%20th May 202127th Aug 2021
Control Flow 2 – Pattern Matching0%0%29th Oct 2021
Imports and Visibility0%0%TBD
GitHub Milestones


RiskImpact (1-3)Likelihood (0-10)Risk (I * L)Mitigation
Copyright assignments224Be up front on all PRs that the code is destined to be upstreamed to FSF
Rust Language Changes3721Keep up to date with the Rust language on a regular basis

Planned Activities

  • Finish TypeCastExpr work
  • Finish cleanup of typebounds branch with super traits

Leave a Reply

Your email address will not be published.