GCC Rust Weekly Status Report 32

Thanks again to Open Source Security, inc and Embecosm for their ongoing support for this project.

Milestone Progress

This report covers work completed since the 1st of November as I took the last week of the 8th off to use some vacation time. During that week, I cracked the problem of handling/managing rust’s lang-item system within gccrs; this unblocked my branch on operator overloading to demonstrate it; thanks to all the bug fixes last month, this seems to be working smoothly. Before operator overloading can be merged, the PR needs to be split up into smaller commits and rebased on top of the recent changes from the community; the DefId change comes to mind as we use this to differentiate between traits.

The community has made a significant dent into all of the lower hanging fruit of good-first-pr’s; there are many more issues like this one the way soon, so keep your eye out if you wish to find your feet to get involved.

So far, I feel like the pace of this milestone is going well, and I am still on track to be about one week over the target date. This leaves us to close out the year by testing the compiler in anger on Blake3 to see how well we get on. Aside from that, I am working on an upcoming blog post reviewing GCC Rust as a project and visiting the major accomplishments along the way in 2021, so keep your eye out for this one.

Thank you to everyone who continues to support and work on the compiler.

Monthly Community Call

We had our 8th community call on 5th November 2021 you can find the meeting notes over here: https://github.com/Rust-GCC/Reporting/blob/main/2021-11-05-community-call.md

Completed Activities

  • Tag ‘rust_fatal_error’ as ‘noreturn’ PR777 PR780
  • Add location info in AST::TypeBoundWhereClauseItem and HIR::TypeBoundWhereClauseItem PR778
  • Add new rust_internal_error for specific ICE’s PR779
  • Merge Type Checking code for enums PR781
  • Refactor TyTy::ADTType into one which can contain multiple variants PR781
  • Get rid of lambda in AST::TypePath PR783
  • Track inline module scopes for path module imports PR785
  • Save make check-rust artifacts for GHA PR787
  • Add new -frust-crate option to specify crate name PR788
  • Get rid of lambda TyTy::TupleType iterate fields PR791
  • Change DefId from uint64_t with bitmask into a struct PR792
  • Fix unhandled TypeBounds PR794
  • Documentation for clang-format usage PR795 PR802 PR803
  • Handle forward declared items within blocks PR796
  • Fix some missing cases of constant folding PR798

Contributors this month

Overall Task Status

CategoryLast WeekThis WeekDelta
TODO9993-6
In Progress1214+2
Completed234244+10
GitHub Issues

Test Cases

CategoryLast WeekThis WeekDelta
Passing48444931+87
XFAIL2121
make check-rust

Bugs

CategoryLast WeekThis WeekDelta
TODO2223+1
In Progress34+1
Completed8486+2
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 – Traits100%100%20th May 202117th Sept 202127th Aug 2021
Control Flow 2 – Pattern Matching55%70%+15%20th Sept 202129th Nov 2021
Macros and cfg expansion0%0%1st Dec 202128th Mar 2022
Imports and Visibility0%0%29th Mar 202227th May 2022
Const Generics0%0%30th May 202225th Jul 2022
Intrinsics0%0%6th Sept 202130th Sept 2022
GitHub Milestones

Risks

RiskImpact (1-3)Likelihood (0-10)Risk (I * L)Mitigation
Rust Language Changes3721Keep up to date with the Rust language on a regular basis
Going over target dates3515Maintain status reports and issue tracking to stakeholders

Planned Activities

  • Merge lang-items work
  • Merge operator overloading work
  • Finish work on adding enum support

Detailed changelog

Refactor TyTy::ADTType

In order to support enums, we could have implemented a new TyTy module for this, to then subsequently update the typechecking code. But in a lot of ways enum’s are just another type of algebraic data type which also has the side effect of canonicalizing the flow of how we work with these types instead of inventing new paths in the compiler. The change here was that the ADT Type was originally designed for unit-structs, structs and tuple structs. But really an enum is an ADT with multiple variants and struts, tuple structs are ADT’s with a single variant and finally, a unit-struct is one with no variants. This change was rather large to decouple and refactor ADT’s into variants but has helped tackle some technical debt along the way. Thanks to @flip1995 for pointing us in this direction.

Add new rust_internal_error

This new API is designed to distinguish between internal compiler errors and actual program errors. Assertions are good but somtimes you want to be able to provide extra contextual information.

Handle forward declared items within blocks

Rust allows for Items such as functions to be declared at the bottom of a BlockExpr which can be referenced at any point within that conxtext such as: https://godbolt.org/z/PGqnz1nve

pub fn main() {
    let a;
    a = foo { a: 123, b: 456f32 };

    let mut a = 123;
    a = bar(a);

    let mut b = 456f32;
    b = bar(b);

    let aa = X;

    let bb:[i32; X];

    fn bar<T>(x: T) -> T {
        x
    }

    struct foo {
        a: i32,
        b: f32,
    };

    const X:usize = 2;
}

Fix unhandled TypeBounds

This test case qithin the rust testsuite https://github.com/rust-lang/rust/blob/d5a0c7cb036032288a4a5443b54ba061ec12ee26/src/test/ui/higher-rank-trait-bounds/hrtb-fn-like-trait-object.rs raised bugs with unhandled type bounds for TypeAlises:

type FnObject<'b> = dyn for<'a> FnLike<&'a isize, &'a isize> + 'b;

The bug here was that we had two ways in HIR to represent bounds here, and we had an opertunity to desugar our AST from two types:

  • AST::TraitObjectType
  • AST::TraitObjectTypeOneBound

Into a single HIR::TraitObjectType

Leave a Reply

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