GCC Rust Weekly Status Report 26

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

Milestone Progress

This week, I finally finished the Rustc Projection Type system for associated types that inherent generic arguments. This was a complex piece of work that ultimately shapes how we handle type-bounds for super-traits and where constraints in general. Now I am working on supporting the TypeBound type from Rustc and generics to detect if a generic type bound is satisfied. The current implementation for type-bounds was designed to be just enough for now to get to the point so we can sensibly work through generic associations. Overall I am on track to finish this core trait work by the end of next week. I think this has taught me a few lessons in my estimates for work in the future.

Monthly Community Call

We had our 6th community call on 3rd September 2021 you can find the meeting notes over here: https://github.com/Rust-GCC/Reporting/blob/main/2021-09-03-community-call.md

Rust Compatibility

With the recent thread on the compiler option strict aliasing we are investigating updating our FAQ on Rust compatibility (Thanks to Philipp Krones) to become:

## What is the plan for inconsistencies in behaviour?

**If gccrs interprets a program differently from rustc, this is considered a bug.**

Once Rust-GCC can compile and verify all Rust programs, this can also help figure out any inconsistencies in the specification of features in the language. This should help to get features right in _both_ compilers before they are stabilized.

The GCC Rust project is not and will not provide a shortcut for getting features into the Rust language. It will follow the well established processes, i.e. RFCs.

We believe that GCCRS should not bypass the Rustc process of getting new language features outside of the Rust processes. The question remains as to the definition of language features, from reading the different perspectives in threads, the definition seems to include common compiler options, warnings or errors, all the way to changing the syntax. So we will take our time before changing FAQ untill we are happy. For more context please read our community call notes.

Linux Plumbers 2021

I will be giving a talk about GCC Rust on the 20th September 2021 at 0900 (us-pacific-time). Find more information over on https://linuxplumbersconf.org/event/11/contributions/911/

Thanks to Miguel Ojeda for reaching out to let me know about the Rust toolchain within the Kernel micro-conference: https://linuxplumbersconf.org/event/11/contributions/970/

Detailed changelog

Qualified Paths In Type

In rust there are two types of qualified paths:

These can also reference generic traits which can have generic associated types. This is where rustc’s Type Projections come into play.

trait Foo<T> {
    type A;

    fn test(a: T, b: Self::A) -> (T, Self::A) {
        (a, b)
    }
}

struct Bar<T>(T);
impl<T> Foo<T> for Bar<T> {
    type A = T;
}

pub fn main() {
    let a;
    a = Bar(123);

    let b: <Bar<i32> as Foo<i32>>::A;
    b = 456;

    let c;
    c = <Bar<i32> as Foo<i32>>::test(a.0, 123);
}

The difficultly in this test case is handling the generic associated type. Since the Placeholder Types don’t support binding of substitutions it took me a while to figure out how to handle this. The only types in the compiler type system that support generic substitutions are algebraic data types and functions (so far). This means the type alias for the associated types needs a method to handle this and this is how projections bind the generic arguments in such a way that a recursive chain is formed to handle this case.

See this commit for more info on the details: https://github.com/Rust-GCC/gccrs/commit/0798add3d3c1bf4b20ecc1b4fa1047ba4ba19759

Completed Activities

  • Generic Qualified Paths PR655
  • Add missing location info to struct fields and cleanup PR652
  • Cleanup Struct Expression classes PR654
  • Qualified Paths PR651

Contributors this week

Excluding merges, 3 authors have pushed 12 commits to master and 15 commits to all branches. On master, 47 files have changed and there have been 928 additions and 1,524 deletions.

Overall Task Status

CategoryLast WeekThis WeekDelta
TODO8989
In Progress76-1
Completed184186+2
GitHub Issues

Test Cases

CategoryLast WeekThis WeekDelta
Passing40954144+49
XFAIL2121
make check-rust

Bugs

CategoryLast WeekThis WeekDelta
TODO1818
In Progress33
Completed6364+1
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 – Traits88%92%+4%20th May 202127th Aug 2021
Control Flow 2 – Pattern Matching0%0%29th Oct 2021
Imports and Visibility0%0%TBD
Macros and cfg expansion0%0%TBD
Const Generics0%0%TBD
Intrinsics0%0%TBD
GitHub Milestones

Planned Activities

  • Finish super-traits work
  • type-bounds in super traits feeds into Where constraints

Leave a Reply

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