Skip to content

Silence missing _ in implementation for items that was suggested to change #89326

Open
@hkmatsumoto

Description

@hkmatsumoto

After #89248 is merged, given the following code: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=131d171b09722b4e0ab4258726edb3a0

trait Foo {
    type Type;

    fn foo();
    fn bar();
    fn qux();
}

struct A;

impl Foo for A {
    type Typ = ();
    
    fn fooo() {}
    fn barr() {}
    fn quux() {}
}

The output will be:

error[E0437]: type `Typ` is not a member of trait `Foo`
  --> src/lib.rs:12:5
   |
12 |     type Typ = ();
   |     ^^^^^---^^^^^^
   |     |    |
   |     |    help: there is an associated type with a similar name: `Type`
   |     not a member of trait `Foo`

error[E0407]: method `fooo` is not a member of trait `Foo`
  --> src/lib.rs:14:5
   |
14 |     fn fooo() {}
   |     ^^^----^^^^^
   |     |  |
   |     |  help: there is an associated function with a similar name: `foo`
   |     not a member of trait `Foo`

error[E0407]: method `barr` is not a member of trait `Foo`
  --> src/lib.rs:15:5
   |
15 |     fn barr() {}
   |     ^^^----^^^^^
   |     |  |
   |     |  help: there is an associated function with a similar name: `bar`
   |     not a member of trait `Foo`

error[E0407]: method `quux` is not a member of trait `Foo`
  --> src/lib.rs:16:5
   |
16 |     fn quux() {}
   |     ^^^----^^^^^
   |     |  |
   |     |  help: there is an associated function with a similar name: `qux`
   |     not a member of trait `Foo`

error[E0046]: not all trait items implemented, missing: `Type`, `foo`, `bar`, `qux`
  --> src/lib.rs:11:1
   |
2  |     type Type;
   |     ---------- `Type` from trait
3  |
4  |     fn foo();
   |     --------- `foo` from trait
5  |     fn bar();
   |     --------- `bar` from trait
6  |     fn qux();
   |     --------- `qux` from trait
...
11 | impl Foo for A {
   | ^^^^^^^^^^^^^^ missing `Type`, `foo`, `bar`, `qux` in implementation

Ideally the output should look like:

error[E0437]: type `Typ` is not a member of trait `Foo`
  --> src/lib.rs:12:5
   |
12 |     type Typ = ();
   |     ^^^^^---^^^^^^
   |     |    |
   |     |    help: there is an associated type with a similar name: `Type`
   |     not a member of trait `Foo`

error[E0407]: method `fooo` is not a member of trait `Foo`
  --> src/lib.rs:14:5
   |
14 |     fn fooo() {}
   |     ^^^----^^^^^
   |     |  |
   |     |  help: there is an associated function with a similar name: `foo`
   |     not a member of trait `Foo`

error[E0407]: method `barr` is not a member of trait `Foo`
  --> src/lib.rs:15:5
   |
15 |     fn barr() {}
   |     ^^^----^^^^^
   |     |  |
   |     |  help: there is an associated function with a similar name: `bar`
   |     not a member of trait `Foo`

error[E0407]: method `quux` is not a member of trait `Foo`
  --> src/lib.rs:16:5
   |
16 |     fn quux() {}
   |     ^^^----^^^^^
   |     |  |
   |     |  help: there is an associated function with a similar name: `qux`
   |     not a member of trait `Foo`

In other words, ideally we could silence missing `...` in implementation for the items informed that a similarly-named item is available.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsP-lowLow priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions