GCC Rust Weekly Status Report 11

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

Milestone Progress

This week there has been no progress change for this milestone but that does not mean no work was done. I have opened a new PR that implements the TurboFish which ensure the compiler iterates all segments in the Path and applies the generic arguments if available to find the appropriate path to a function/constant etc, this change involves a few building blocks. For example, in rust, you can create an impl block for multiple concrete versions of a generic algebraic data type ISSUE-325.

struct Foo<T>(T, bool);

impl Foo<i32> {
    fn bar(self) -> i32 {
        self.0
    }
}

impl Foo<f32> {
    fn bar(self) -> f32 {
        self.0
    }
} 

fn main() {
    let a = Foo(123, true);
    let aa = a.bar();

    let b = Foo(456f32, true);
    let bb = b.bar();
}

This change means we needed to implement Canonical Paths for the name resolver so as we don’t detect duplicate names for the two impl blocks. There are caveats here in that we can end up in a case where we might find multiple applicable items in Path resolution such as ISSUE-355.

The open PR however still does not address the case of overlapping impl items such as: ISSUE-353

Detecting unused code

Recent we have merged PR-365 from a potential Google Summer of code student Thomas who wishes to improve our unused code diagnostic warnings. This includes using liveness variables to follow code paths such as:

fn bar() {
    foo();
}

fn foo() {
    bar();
}

fn f() {
} 

fn main() {
    f();
}

Now results in:

../gccrs/gcc/testsuite/rust.test/xfail_compile/unused.rs:2:1: warning: function is never used: `[bar]`
    2 | fn bar() {
      | ^
../gccrs/gcc/testsuite/rust.test/xfail_compile/unused.rs:6:1: warning: function is never used: `[foo]`
    6 | fn foo() {
      | ^

Empty Arrays Crash

Another potential Google Summer of code Student Yizhe has also fixed crashes with empty arrays which are valid in rust:

fn main() {
    let arr = ["Hello"; 0];
}

Completed Activities

  • Raised PR for canonical paths: PR-358
  • Raised PR for multiple applicable items in scope: PR-358
  • Raised PR to implement TurboFish: PR-358
  • Fix crash with zero length arrays: ISSUE-260
  • Add initial liveness variables for dead code detection: ISSUE-330 PR-365

Overall Task Status

CategoryLast WeekThis WeekDelta
TODO5761+4
In Progress611+5
Completed107110+3
GitHub Issues

Test Cases

CategoryLast WeekThis WeekDelta
Passing838861+23
XFAIL2626
Failed00
XPASS00
make check-rust

Bugs

CategoryLast WeekThis WeekDelta
TODO1213+1
In Progress26+4
Completed2526+1
GitHub Bugs

Milestones Progress

MilestoneLast WeekThis WeekDeltaStart DateCompletion DateTarget
Data Structures 1 – Core100%100%30th Nov 202027th Jan 202129th Jan 2021
Control Flor 1 – Core100%100%28th Jan 202110th Feb 202126th Feb 2021
Data Structures 2 – Generics72%72%11th Feb 202128th May 2021
Data Structures 3 – Traits0%0%27th Aug 2021
Control Flow 2 – Pattern Matching0%0%29th Oct 2021
Imports and Visibility0%0%TBD
GitHub Milestones

Risks

RiskImpactLikelihoodRisk (I * L)Mitigation
Copyright assignment2510
Be up front on all PRs that the code is destined to be upstreamed to FSF
Rust Language Changes3721
Keep up to date with the Rust language on a regular basis

Planned Activities

  • Merge open PR for canonical paths and proper turbo fish implementation
  • Detect overlapping impl items: ISSUE-353
  • Detect for unconstrained generic arguments in impl blocks: ISSUE-354
  • Continue work on default generic arguments: ISSUE-307

Leave a Reply

Your email address will not be published.