GCC Rust Weekly Status Report 22

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

Milestone Progress

Last week saw more building blocks being merged to enforce a trait’s constraints onto an impl block. What bjorn3 pointed out, which is pretty neat, is that a super trait is syntatic sugar for a Self TypeParameter with a TypeBound of the super trait. This means we will reuse the same TypeBounding code to get this support for free so long as it is implemented correctly.

All of this work is to tackle the optional trait items such as functions that will need my TypeBounding branch to do anything useful since a trait function item is pretty much a generic function with an implicit Self Type Parameter.

Throughout this Traits milestone, I’ve realised that many subtle things are going on in the rust compiler to implement it correctly. Most of all, a lot of this behaviour is just not documented. I think a complete language reference could address it, such as method resolution rules that affect users of the language, not just compiler developers.

Google Summer of Code

Great progress for both students, thanks for all your hard work.

Cargo Support

Arthur Cohen is still focused on the functional test harness work which is key to completing his GSoC goals. Apart from that, he has been unifying the interfaces to support common options such as config printing, which includes adding support for environment variable arguments to the compiler such as GCCRS_EXTRA_ARGS etc.

Static Analysis

Wenzhang Yang has completed all the goals of his GSoC proposal, so now he is blocked due to missing pattern matching for example. We have now scoped out further work to fix our unused variables/mutability scan. This fits well within his experience and should be achievable between now and the end of GSoC.

Detailed changelog

Associated Type Errors

Extending from last week the placeholder types are not updated as part of the Trait impl block resolution so we can enforce rules where the TypePath to Self::A is properly enforced such as:

trait Foo {
    type A;

    fn baz(a: Self::A) -> Self::A;
}

struct Bar<T>(T);

impl<T> Foo for Bar<T> {
    type A = i32;

    fn baz(a: f32) -> f32 {
        // { dg-error "expected .i32. got .f32." "" { target *-*-* } .-1 }
        // { dg-error "method .baz. has an incompatible type for trait .Foo." "" { target *-*-* } .-2 }
        a
    }
}

fn main() {
    let a;
    a = Bar::<i32>::baz(123f32);
}
test.rs:12:15: error: expected [i32] got [f32]
    4 |     fn baz(a: Self::A) -> Self::A;
      |               ~
......
   12 |     fn baz(a: f32) -> f32 {
      |               ^
test.rs:12:5: error: method ‘baz’ has an incompatible type for trait ‘Foo’
    4 |     fn baz(a: Self::A) -> Self::A;
      |     ~
......
   12 |     fn baz(a: f32) -> f32 {
      |     ^


Missing Trait Items within Impl Block

trait Foo {
    const A: i32;

    fn test(self);
}

struct Bar;
impl Foo for Bar {}
test.rs:8:1: error: missing A, test in implementation of trait ‘Foo’
    2 |     const A: i32;
      |     ~
    3 | 
    4 |     fn test(self);
      |     ~
......
    8 | impl Foo for Bar {}
      | ^

Some items are optional and should not cause this error for example a function with a block this does not cause this error.

Completed Activities

  • Cleanup and comments to DeadCode Pass PR571 PR564 PR562
  • Warn for unused impl items via DeadCode pass PR567
  • Add missing DefId mappings PR568
  • Add const modifier to TyTy equality interface PR572
  • Add missing test cases to close out unit-structs PR570
  • Some Trait items are optional and should not error PR569
  • Enforce mandatory trait items and placeholder type checking PR566

Contributors this Week

Overall Task Status

CategoryLast WeekThis WeekDelta
TODO8887-1
In Progress78+1
Completed163166+3
GitHub Issues

Test Cases

CategoryLast WeekThis WeekDelta
Passing32023402+200
XFAIL1515
make check-rust

Bugs

CategoryLast WeekThis WeekDelta
TODO2020
In Progress33
Completed5253+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 – Traits43%54%+11%20th May 202127th Aug 2021
Control Flow 2 – Pattern Matching0%0%29th Oct 2021
Imports and Visibility0%0%TBD
GitHub Milestones

Risks

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

  • Optional trait items
  • Implement Initial Coercion Rules
  • TypeCasts type checking

Leave a Reply

Your email address will not be published.