GCC Rust Weekly Status Report 12

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

Add check for duplicate overlapping impl-items

Rust allows for multiple impl blocks to give specialisation to a generic data type. But if the programmer adds a generic impl for a dup method it will become impossible to distinguish the method ‘bar’ in each of these specialised impl blocks when it comes to method resolution. Since you receiver could be Foo<_ (inference variable)> which could resolve to Foo or Foo. rustc –explain E0592

struct Foo<A>(A);

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

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

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

Check for unconstrained type parameters

When we declare generic impl blocks but don’t use all of the type arguments within the generic data type we end up with unconstrained type parameters. This is important since we rely on the Self of the impl block to bind all of the substitutions relevant to the impl block. See rustc –explain E0207

struct Foo<T>(T, bool);

impl<X, Y> Foo<X> {
    fn test() -> Y {
        self.0
    }
}

Multiple candidate errors

Similar to the duplicate overlapping impl items each of theses specialised impl blocks are valid and there is no overlap here. The problem arises when the programmer tries to resolve this path but using the Path Foo::test without any generic argument specialisation, the resolver will find both ‘test’ impl item as candidates. This can be fixed if the programmer uses Foo::::test for example. rustc –explain E0034

struct Foo<A>(A);

impl Foo<isize> {
    fn test() -> i32 {
        123
    }
}

impl Foo<f32> {
    fn test() -> i32 {
        123
    }
}

fn main() {
    let a: i32 = Foo::test()
}

Rich locations

We have also merged a building block to take advantage of GCC’s rich location diagnostics for errors such as the multiple candidates error we had to emit multiple errors for each location. Now with rich locations we can add ranges/fixit hints at specific locations and emit one single error which makes diagnostics much easier to read for users of the compiler. There is alot of scope in terms of improving errors over time and rich locations are the first step in this direction.

Testsuite updates

Thanks to Thomas’s work we have jumped our test suite number of passes by including checking for warnings emitted by the compiler this will help a lot with detecting any regressions/changes in behaviour.

Completed Activities

  1. Merged building block for using GCC rich locations: PR374
  2. Merged canonical path work: PR358
  3. Merged TuboFish work: PR358
  4. Merged fix for crash in generic impl blocks with different type parameter names: PR377
  5. Merged check for unconstrained type parameters: PR378
  6. Merged testsuite to scan for warnings and errors: PR362

Overall Task Status

CategoryLast WeekThis WeekDelta
TODO6162+1
In Progress118-3
Completed110118+8
GitHub Issues

Test Cases

CategoryLast WeekThis WeekDelta
Passing8611921+1060
XFAIL2636+10
Failed00
XPASS00
make check-rust

Bugs

CategoryLast WeekThis WeekDelta
TODO1312-1
In Progress64-2
Completed431+5
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 – Generics72%79%+7%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

RiskImpact (1-3)Likelihood (0-10)Risk (I*L)Mitigation
Copyright assignments2510Be 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

  • Continue default generic argument work
  • Review contributor NeverType work updates

Leave a Reply

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